11.2. Evaluation

Expressions in Gamma consist of a few basic types, which are submitted to an evaluator to produce a return value. Every evaluation returns a result. Any Gamma object may be submitted to the evaluator. The evaluator behaves differently according to the type of the evaluated object.

Table 11.1. Type Evaluation
Type of ObjectEvaluation result
symbolThe value of the symbol in the current scope.
listFunction or method call.
all othersItself.


11.2.1. Evaluation of a Symbol

If a symbol is being used as a variable, then its value will depend on the scope in which it is being evaluated. A new scope is entered whenever a user-defined function is executed, or when a with statement is executed. A symbol is defined within a scope when it appears in the argument list of a function, or when it appears in the variable list of a local statement. If a symbol is not defined within the current scope, then the value of the symbol in the next most local scope is used. This is called dynamic scoping, since the scope of a symbol used in a function may depend on the calling sequence that executed that function. The value of a symbol may be any Gamma object. See examples on dynamic scoping in Tutorial II.