[Newbies] Re: A do with ONLY index? (plus,. a style question)
Blake
blake at kingdomrpg.com
Fri Feb 9 08:15:43 UTC 2007
On Thu, 08 Feb 2007 22:58:32 -0800, Klaus D. Witzel
<klaus.witzel at cobss.com> wrote:
> Sure. Evaluate "Object halt; new" with doIt and then in the debugger, in
> the DoIt method line push the buttons "Through" then "Into".
Aha.
Huh.
Why doesn't this:
^ self basicNew initialize
cause a DNU? Object doesn't have an "initialize" method.
> But yes we care :) The default initializer is Object>>#initialize, an
> empty method with is executed at primitive speed (it just returns self).
> Before that, #basicNew (the primitive) has already initialized the new
> instance with all nil's (or zeros, depending on the class' format spec).
> From the ~ 2887 classes in my Squeak-dev image, only some 928 implement
> initialize (even less when subtracting all the class side implementors).
>
> So yes, it's quite common behavior to let the user set something
> actually useful.
I wasn't clear. I'm accustomed to creating "reasonable defaults" for
instances. In a lot of cases, this has struck me as dumb, since there are
no reasonable defaults. I thought I saw the same thing going on in Squeak
but that doesn't seem to be the case.
More information about the Beginners
mailing list