[   ^ to index...   |   <-- previous   |   next -->   ]

A word about access protection

Smalltalk classes have no access protection mechanisms for their methods.

However, only methods of an object have access to the object's instance variables. Since classes inherit their superclasses' instance variables, subclass instances may access variables defined in a superclass.

In C++ terms, all instance variables are protected, and all methods (member functions) are public.

Hence, in Squeak, where everything is implemented in Smalltalk, you can freely change everything about the world, up to and including the implementation of message sending, subclassing, and closure evaluation. Doing such things will break literally everything in your environment, of course.

A chink in the armor

Smalltalk people like to talk about how "everything is an object", as if the entire description of the language were self-evident once you understand this principle.

However, what is a variable? When I say "x := 3", we are binding the object 3 to x; but is x itself an object that exists before we perform this assignment? In other words, is assignment a message that you send to a variable object? The answer is no: assignment is not a message at the language level. Variables are not objects; they are names for objects.

Aside: a bit of ugliness

I said earlier that

This implies that classes have a class. This is, in fact, true. For every class in the system, there exists a "meta-class", which is the class of that class.

Now, these classes of classes are are themselves objects, so they, too, must have a class---which is Metaclass. In other words, the class of a class is an instance of Metaclass. And Metaclass's class is simply an instance of MetaClass---in other words, the class of Metaclass is one of its own instances...

    "Smalltalk expression"                  "Result of printIt"
    x := 3.                                 3
    x class.                                SmallInteger
    x class class.                          SmallInteger class
    x class class class.                    Metaclass
    x class class class class.              Metaclass class
    x class class class class class.        Metaclass
    x class class class class class class.  Metaclass class
    " ... etc."

Keunwoo Lee
Last modified: Thu May 10 00:36:21 PDT 2001