Category:Smalltalk: Difference between revisions

Content added Content deleted
Line 223: Line 223:


=== Variables and Scope ===
=== Variables and Scope ===
Variables are used to name objects. Actually they are bindings of a name to an object. Objects can only be passed and used by reference, and access to an object's internals is not possible from outside the object's own method implementation, although most classes inherit from Object, which provides some reflection protocol to access instance variables or to query for the class. However, such inherited reflection mechanisms could be overwritten in a class or a class could not inherit from Object, to prevent even access from debuggers and inspectors.
Variables are used to name objects. Actually they are bindings of a name to an object. Objects can only be passed and used by reference, and access to an object's internals is not possible from outside the object's class methods, except though getters and setters; although most classes inherit from Object, which provides some reflection protocol to access instance variables or to query for the class. However, such inherited reflection mechanisms could be overwritten in a class or a class could not inherit from Object, to prevent even access from debuggers and inspectors.


Smalltalk is lexically scoped, and outer variable bindings are closed over when a block (=lambda closure) is created.
Smalltalk is lexically scoped, and outer variable bindings are closed over when a block (=lambda closure) is created.