Can a constant be global?
Robert Brenstein
rjb at robelko.com
Mon Mar 27 07:04:25 EST 2006
>This is another of those things that I've lived without for years -
>I normally use globals to contain text strings which may change if
>the human language of the app changes (what is the Welsh for
>"Cancel"? - don't know, but I know someone who can tell me!), so
>that all the values can be initialised in one handler when the app
>starts up: but after all this time I thought I'd try using constants
>instead.
>
>However neither the RR documentation nor my experiments seem to
>suggest that there is a way of making constants global (i.e
>constant). Can this really be true? If so, they have a crushing
>disadvantage with respect to globals. After all, RR's own constants
>are global. I guess I've missed something.
>
>Thanks to anyone who can dispel another of my clouds of ignorance.
>
>Graham
>
RR's own constants are global because they are part of the language
so do speak. As such, they are defined in the engine. That makes them
a different beast than constant defined in your scripts.
Replicating constant behavior at global level has been discussed
quite a lot in the past, and not only on this list, but... it is a
lot more complicated than it seems at first glance. So, for now at
least, there is no way to make a global behave like a constant
through declaration. It is up to you to designate some globals as
global constants, like using a different prefix than for global
variables.
Robert
More information about the use-livecode
mailing list