A note on lexical scoping rules

<< Click to Display Table of Contents >>

Navigation:  Basic concepts > Procedures and functions >

A note on lexical scoping rules

Before GP Script 4.6 there were just two lexical scopes, global and local. System functions and variables declared outside of callbacks or functions are global while variables declared inside callbacks and functions are considered local.

 

You can declare local variables who names are the same as global variables and even system functions and those local names will "hide" the global names.

 

However, you could not declare a global name (variable or function) that was the same as a system function as all are in the same global lexical scope.

 

As of GP Script 4.6, system functions are now declared at a higher "system level" scope and so can be overridden by your own global declarations.

 

The reason for this change is to avoid breaking existing user code if we introduce a system function name that happens to have the same name as a user's global declaration.