drvaughan55 at mac.com
Mon Aug 26 22:07:01 EDT 2002
On Tuesday, August 27, 2002, at 12:52 , Rob Cozens wrote:
>>> The global keyword is adopted from HyperCard 1.0, and has been a part
>>> of all
>>> xTalk implementation since. How else would the engine know whether
>>> to treat
>>> a variable as local or global without such a keyword?
>> Presumably it would maintain a list and then every time you used a
>> variable, it would have to check to see if it was in the list. But
>> once you added a variable to the list, you would never have to add it
>> again, which would be a nice feature.
> Whoa Mark,
> That would mean every time one wrote a handler one would have to check
> EVERY local variable name to make sure it was not on the global list.
> This would include handlers in other people's stacks as well as your
> As an aside, just as Revolution has less need to use externals than
> HyperCard, it also has less need to use global variables. One can
> define local variables that are shared by all handlers in a script and
> whose values persist until the stack is closed.
...and that is the key: declaring global or local variables at the top
of scripts rather than in handlers. It was one of the immediate changes
I made to HyperCard-patterns of scripting. Better yet, I basically never
use globals anyway. On the occasions a local declaration will not serve,
I prefer a custom property (of any suitable object). It is globally
accessible, persistent and non-conflicting with other variable naming.
> I was able to replace all globals in my original HyperCard library
> design with locally-declared variables.
> Rob Cozens
> CCW, Serendipity Software Company
> "And I, which was two fooles, do so grow three;
> Who are a little wise, the best fooles bee."
> from "The Triple Foole" by John Donne (1572-1631)
> use-revolution mailing list
> use-revolution at lists.runrev.com
More information about the use-livecode