Subscribe Bookmark RSS Feed

Name resolution and Scoping

I have the following two questions about JSL name resoution and scoping:

1. Both :height and column("height") refer to a column in the data table. Is it correct that if I assign X=column("height"), X will be a global variable? Is there any way to make X under some sort of "local" sense?

2. By using function( , {default local}, ), most of the variables inside the function will be local variables. Is there any similar option for expr( ) ? I'm writing a program which calls several functions, some of which share the same variable names. I'm using expr( ) for now, but am afraid there would be conflict if too many global variables float around.

Many thanks!
Yes x will be global. For example, I can have a declaration such as:

height = 10;

In which case I will have 2 variables with name height but with different scope (global and table), however if I write:

a = Column("height");

I do not have 2 variables; the second expression will overwrite the original value of 10.

JSL has a LOCAL function which defines a list of local variables that are only valid within the block:

Local( {localVar1, localVar2},
//block of code here
That's very helpful! Thank you! I'll try the local( ) function.