[Newbies] Re: Re: A do with ONLY index? (plus, . a style question)
Michael van der Gulik
mikevdg at gulik.co.nz
Sun Feb 11 01:25:52 UTC 2007
Blake wrote:
> On Fri, 09 Feb 2007 02:54:14 -0800, Klaus D. Witzel
> <klaus.witzel at cobss.com> wrote:
>
>>> Why doesn't this:
>>>
>>> ^ self basicNew initialize
>>>
>>> cause a DNU? Object doesn't have an "initialize" method.
>>
>>
>> Really ? :) It is inherited from ProtoObject ;-)
>
>
> Wow, don't know how I missed that.
>
> I guess maybe partly because the debugger doesn't go into the method
> (because it's blank, I suppose).
Actually, the method isn't blank, it's actually "^ self", except that
that part is added automatically and you don't see it.
See here:
http://users.ipa.net/~dwighth/smalltalk/bluebook/bluebook_chapter27.html#CompiledMethods27
One of the optimisations in Smalltalk is that a method that's just "^
self" actually doesn't have any bytecodes but just a special flag in the
method header. Glossing over a few details, the Interpreter picks this
up and skips over it.
It's interesting to play with the right-most button on the Browser -
click it and see the bytecodes or the "decompilation" of source.
Michael.
More information about the Beginners
mailing list