[comp.sys.mac.programmer] Globals in SAC musings

wieser@fsd.cpsc.ucalgary.ca (Bernhard Wieser) (03/05/91)

Salve!

I've been debating the best way to achieve global variables in stand alone
code.  From people I've talked to I've heard some of the following
techniques.

1) dummy resource
Build yourself a resource with some scratch space and let the resource
manager deal with it.  Use the handle as your base reference.  Lock it
into memory at some point, but be sure to do some sanity checking to
make sure it's really yours.  Just call the resource manager to refresh
your local handles.  Never really have to save its contents.

2) tech note 256 - create your own reality (or A5 world)
Create a handle and maintain the A5 world which is real (someone else's
globals) or un-real (your globals).

I like #1, since #2 means taking care of reality carefully to ensure it
does not collapse.  Of course #1 means you must always remember exactly
where your variables are relative to your base, perhaps best done in
68k, but at least you don't have to worry about non-existence.

Please e-mail me suggestions/comments/other brill. ideas.

Vale!



-- 
(    Bernie Wieser, wieser@cpsc.ucalgary.ca, BSWieser@uncamult.BITNET    )
(    4rth Year Dbl.Mgr Cpsc Clhc University of Calgary     |             )
(    S/H Developer Dept. of Psychology, "   "   "         \|/            )
(    Octavian Micro Development Group                  --- o ---         )