Node:Visibility, Next:, Up:Declarations



Visibility

Q is statically scoped. A variable x is visible in the entire scope containing its declaration :x, not just after the :x is evaluated. So the "memory location" for all variables declared in a scope are actully allocated when the scope is entered. There can be only one defining instance of a variable in a scope (i.e. the name of variable must be prefixed by : once and once only). It is conventional that the defining instance be the first one, but that is not required. (It may not be possible in the case of mutually recursive function.) An example: (:x = y; :y = 10; x) evaluates to 10.

(We can say that all declarations are mutually recursive. The one exception is for Q commands typed in interactively. In that case, the declaration is not visible until the command contianing it has been read in, of course!)