About removing global variables

Avi Bryant avi.bryant at gmail.com
Sun Nov 28 12:37:31 UTC 2004


On Sun, 28 Nov 2004 13:03:51 +0100, stéphane ducasse
<ducasse at iam.unibe.ch> wrote:

> But you argument about typing less is not really sexy since this
> is true that is is shorter to type Smalltalk than Namespace smalltalk
> but you block the fact that we can have multiples ones.

In one sense we can already "have multiple ones", since a reference to
Smalltalk is not a hardcoded pointer to a specific object but a late
bound reference to an association.  I can change what Smalltalk refers
to by doing "Smalltalk at: #Smalltalk put: somethingElse", and now
every method that uses Smalltalk will get my new object without having
to be recompiled.  This is Good.

The problem is that the late binding mechanism used for this is
over-optimized; instead of sending a message to the association, it
simply grabs the second indexed instance variable.  This is, in my
opinion, Very Bad.  If it were a proper message send of #value, then
we could implement new kinds of associations that defined new
semantics for variable lookup, and the meaning of "Smalltalk" or
"CurrentNamespace" could depend on whatever you want.

This is, of course, assuming that we have global variables at all. 
I'd also be happy with a Self-like approach, where a reference to
Smalltalk was simply a shorthand for "self Smalltalk" (and Array was a
shorthand for "self Array", etc).

Avi



More information about the Squeak-dev mailing list