[squeak-dev] Class with nil environment?!
David T. Lewis
lewis at mail.msen.com
Thu Jul 11 00:01:11 UTC 2013
On Wed, Jul 10, 2013 at 06:50:09PM -0400, Bob Arning wrote:
>
> On 7/10/13 5:59 PM, Frank Shearar wrote:
> >Well, with my nil-hating hat on, I'd say that Class >> #environment is
> >also busted. There's no value in having environment = nil.
Well ok but ... this isn't Java you know, so you don't need to hate
a perfectly respectable object just because it happens to represent
nothingness ;-)
>
> It allows subclasses to track the superclass environment. You can change
> the environment for a class and all subclasses that have not explicitly
> declared an environment will share it. Subclasses that have had an
> explicit environment set will keep that that even when the superclass
> changes.
>
> >You're not
> >saving any space, for instance. What you _do_ have is a piece of
> >uninitialised state, waiting for someone to reference the instvar
> >directly (as Class >> #declare: does) and fail with an MNU on nil.
> >
> >I'm waiting to hear what Colin has to say, but I'd say that Class >>
> >#declare: has every reason to assume that an instvar's initialised,
> >and that #environment should simply say "^ environment".
>
> The counter-argument, of course, is to use the accessors and not tinker
> directly with the instvars unless you are sure you know what you are doing.
That sounds like good advice to me.
And I agree with Frank that we should hear what Colin has to say about it.
Dave
More information about the Squeak-dev
mailing list
|