For Programmers: Free Programming Magazines  


Home > Archive > Smalltalk > May 2006 > Re: what's the problem here ( n timesRepeat:)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: what's the problem here ( n timesRepeat:)
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.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com