Previous Up Next

Identifiers

The names of local variables, formal parameters of methods, \(\rm self\), and class attributes are all expressions. The identifier \(\rm self\) may be referenced, but it is an error to assign to \(\rm self\) or to bind \(\rm self\) in a \(\rm let\), a \(\rm case\), or as a formal parameter. It is also illegal to have attributes named \(\rm self\).

Local variables and formal parameters have lexical scope. Attributes are visible throughout a class in which they are declared or inherited, although they may be hidden by local declarations within expressions. The binding of an identifier reference is the innermost scope that contains a declaration for that identifier, or to the attribute of the same name if there is no other declaration. The exception to this rule is the identifier \(\rm self\), which is implicitly bound in every class.

Previous Up Next