Newbie q
goran.krampe at bluefish.se
goran.krampe at bluefish.se
Sat Sep 27 12:26:38 UTC 2003
Jecel Assumpcao Jr <jecel at merlintec.com> wrote:
> On Friday 26 September 2003 10:52, Phil Hudson wrote:
> > Thanks Göran. I'm convinced.
>
> Awww... you gave up too easily. In the Self dialect of Smalltalk (those
:-)
> of you thinking of writing me that "Self isn't Smalltalk", please don't
> bother) a context is created by cloning the method object. So any
> temporary variables should have valid values *before* execution starts.
>
> Something like
>
>
> myMethod: arg = (
> | x <- 10. y <- 'Hubba'. z = picture from: 'FCD045F07' |
> ....
> )
>
> The 'z' temporary variable is actually a constant rather than a
> variable, which if one thing you can't have when initializing in the
> method body instead of the declarations. Another subtle difference
> relative to
>
> myOtherMethod: arg (
> | x. y. z |
> x: 10.
> y: 'Hubba'.
> z: picture from: 'FCD045F07'.
> ...
> )
>
> is that now the code for these initializations is executed each time the
> method is invoked, while in the first example they were executed while
> creating the method object. The really makes little diffence for things
> like 10 or 'Hubba', but if the picture creation method is slow then the
> first version is much more interesting.
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". :-)
> Yes, Smalltalk has been around for 31 years now. But it is never to late
> to learn new tricks ;-)
>
> -- Jecel
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.
regards, Göran
More information about the Squeak-dev
mailing list
|