next up previous contents
Next: Assignment Up: Expressions Previous: Constants   Contents

Identifiers

The names of local variables, formal parameters of methods, self, and class attributes are all expressions. The identifier self may be referenced, but it is an error to assign to self or to bind self in a let, a case, or as a formal parameter. It is also illegal to have attributes named 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 self, which is implicitly bound in every class.