Distinctions, Labels, and Smalltalk

In Smalltalk, objects *are* distinctions. Since everything in Smalltalk is an object, then everything in Smalltalk is a Distinction.

If we look at this in terms of the piece of paper analogy, instance variables inside an object are circles inside an enclosing circle. To distinguish between instance variables in the context of an object, we typically name them just like we name circles. See Doughnut.

In Smalltalk, assignment lets us name any distinction by applying a label. Since everything in Smalltalk is a distinction, then everything in Smalltalk can be named. This is an extraordinary ability to have.

> In some Smalltalks, assignment is written as ← instead of :=. This gives the wrong impression as well. It would be much better to use → or :>.

Note that assignment should not be interpreted as loading a value into some named memory cells. Naming an object should not be seen along the lines of modifying the object to hold its name either. On the contrary, the act of giving a name should be thought of in terms of remembering an object by means of a label. Also, since a distinction is not the private property of the name either, you are free to give a distinction as many names as you want.

Commonplace keywords like `instanceVariableNames:` and expressions such as “temporary variable names” take a whole new meaning from this point of view. In fact, they should not even contain the term variable at all. Therefore, we will not refer to names by means of, or assisted by, the word *variable* any further.

> Note how without the word variable, this statement becomes trivial.

Ideas like instance name encapsulation also take a new powerful meaning when viewed in terms of distinctions. Instance names live inside the boundary of instances, thus in order to get at them the boundary of the instance has to be crossed.

Since everything that happens in Smalltalk occurs in terms of messages, it turns out that messages are the only entities that can cross boundaries, possibly carrying other objects (distinctions) with them.

> Did we mention Alan Kay has a biology background?

Compare this mass of distinctions and messages crossing boundaries with other complex systems in which objects interact. One example could be a live multicellular being such as yourself, in which multiple cells typically influence the behavior of each other by means of protein messages which cross cell membranes.

Or let’s say you would like to have lunch with a friend. In an assembler or obfuscated C world, you would reach inside your friend’s mind and manipulate values and pointers until you made lunch appear attractive. You might even tickle the stomach to get the appetite going.

But Smalltalk imposes much more civilized manners. In the same way that your friend is not a `struct{...}`, objects are not allowed to arbitrarily cross distinctions and mess with internal details. Instead, objects must communicate by means of messages. As long as the agreed upon behavior is respected, the implementation artifacts are happily taken for granted.

If we keep in mind that everything in Smalltalk is a distinction, and that all distinctions can be named, then it follows that it must be possible to name every distinguished bit of behavior. In Smalltalk, the names of bits of behavior are called *selectors*.

Smalltalk sentences are no more than invocations of bits of behavior, where the specific behaviors in question are distinguished and called upon by means of their selectors.

Since messages provide the only mechanism to cross into a distinction, it obviously follows that even the behavior named `instVarAt:` must be a message.

~

For those not familiar with the message `instVarAt:`, what sending it does is to answer the object referenced by the nth instance name of the receiver. This works because all instance variables are stored in the order given by the Class and superclass definitions. Feel free to check out the implementation in your Smalltalk of choice.

.