scope (was: Newbie q)

Jecel Assumpcao Jr jecel at merlintec.com
Mon Sep 29 14:40:01 UTC 2003


On Saturday 27 September 2003 09:26, goran.krampe at bluefish.se wrote:
> It seems to me that the first and the second "differences" here are
> the same.
> The big point is that there is a value that is created at the time of
> writing the method instead of every time it is run. Thus the value is
> not IMHO a method temporary, it would more suitably be in a class
> var, class instvar or pool var.
>
> But I agree that it could be neat with such a mechanism - not sure
> though that it "buys me enough". :-)

All very true. What this buys me is not having to put such objects in a 
more global scope than needed by the application due to language 
limitations. If the object is used strictly in a single method, then 
making it a class or pool variable is the wrong thing to do.

Another subtle problem of putting the object in a class or pool variable 
is that you have to be sure to run the code that initializes them 
before you ever call the method that uses them. Ok, you might use laze 
initialization for that.

> > Yes, Smalltalk has been around for 31 years now. But it is never to
> > late to learn new tricks ;-)
>
> Indeed - I definitely did not want to imply that it can't be
> improved! I just meant that most issues have been discussed at length
> so there is most probably material around to read etc.

True again! But most people here haven't read about Self, Kevo, Us and 
other early 1990s stuff, much less the 40 year old things Alan always 
likes to point out. So we can't assume that something that hasn't been 
adopted by Squeak has been carefully considered and then rejected for 
some reason or another.

-- Jecel



More information about the Squeak-dev mailing list