| Chronos 2006-05-04, 4:10 am |
| The following code should work in any Smalltalk implementation that has
the global #Transcript:
| times |
times := 3.
times timesRepeat: [Transcript space].
Whether the receiver of a message (such as #timesRepeat:) is
a literal, or is referenced by a variable, makes no difference.
Smalltalk does not have "constants" in the syntactical sense,
only literals and variables (or more accurately, literals and
identifiers.)
What matters in Smalltalk is the class of the value that receives a
message, which is an intrinsic property of each value, regardless
of how the value is referenced syntactically.
Or to put it another way: Object encapsulation in Smalltalk requires
the absence of any static binding between a value and whatever
variables may reference it. From the perspective of those who
invtented OO, and coined the term "object-oriented," linking the
class of a value to the variable that references it breaks object
encapsulation. The inventors of OO maintain that a value is an
object if, and only if, it fully encapsulates both its state and its
behavior. So called "objects" in the mainstream programming
languages do neither.
|