cross-stack globals, also, file inclusion

J. Landman Gay jacque at
Thu Oct 23 11:27:47 EDT 2003

On 10/23/03 9:05 AM, Rob Cozens wrote:

> Hi Jacque,
> Do you really see custom properties as the preferred means of declaring 
> constants?  Suppose pi was not a built-in constant.  Would you "get the 
> piConstant of this stack" for every stack that used pi? Would you "get 
> the piConstant of stack constantLibrary" or "get line piConstantLine of 
> the constantList of stack constantLibrary" (with piConstantLine being 
> another constant)?

Yes, I'd get it for each script that needed it if it weren't used too 
often, and I might even get it individually for each handler if it were 
only very rarely used. If it were used all over the place, I'd put the 
value into a global variable just once on startup or openstack.

I think you mentioned needing to load hundreds of constants. For 
something like that, I'd store them all as an array in a custom property 
and just load the array into a global variable when the stack opened. 
It's very fast.

> If one must "set the piConstant of this stack to 
> 3.14159265358979323846", what's the advantage over "constant piConstant 
> = 3.14159265358979323846" in the stack script?

Well, of course, we can already do this; the only difference is that the 
constant is script-local rather than global. Loading the value into a 
global variable would take care of that. As Pierre mentioned, the 
primary advantage is simply in keeping the language elegant and 
streamlined. There is already a means to do what we want. Understand 
though that I have no particular objections to adding global constants, 
I just don't see the need for them, nor have I ever missed them in my 17 
years of scripting.

Jacqueline Landman Gay         |     jacque at
HyperActive Software           |

More information about the Use-livecode mailing list