Richard Gaskin ambassador at
Tue Aug 27 11:46:01 EDT 2002

Rob Cozens wrote:

> First, lets make sure we are using the same terms.  There is a
> difference between "locally-declared" variables and "local"
> variables.  HyperTalk allows:
> 1. global variables, whose values persist until the engine quits and
> are accessible to any handler in the runtime environment.
> 2. local variables, whose values persist only so long as the handler
> runs and are accessible only to that handler.
> The MetaCard engine recognizes a third type, locally-declared
> variables, whose values persist until the stack closes and are
> accessible to any handler in the script.

This latter type is sorta halfway between what VB and other languages call
"static variables" and what the OOP world calls "private variables".  It may
have been less confusing if MC had adopted a new "static" keyword to reflect
this very different type of declaration.

But once you get the hang of using static vars in MC, it may well change
your programming style dramatically.  These are especially useful for
helping to keep code well factored, as they avoid the inter-object name
space collisions that make globals problematic, yet persist as globals do.
Perfect for making discrete libraries.

Also, FWIW the revised Script Style Guide was updated to include reference
to this new variable type:

 Richard Gaskin 
 Fourth World Media Corporation
 Custom Software and Web Development for All Major Platforms
 Developer of WebMerge 2.0: Publish any Database on Any Site
 Ambassador at
 Tel: 323-225-3717                       AIM: FourthWorldInc

More information about the Use-livecode mailing list