Eliminating assignments and variable syntax (accessors)

Marcel Weiher marcel at system.de
Mon Aug 2 22:43:54 UTC 1999


> From: Alan Lovejoy <sourcery at pacbell.net>
> > ** Original Sender: Marcel Weiher <marcel at system.de>
> > Well, I guess that is the part that got sort of lost in the noise:    
> > If there are no accessors, the compiler compiles 'accessor/mutator'   
> > message sends to self as direct variable access.  Therefore, the   
> > object itself can access its own instance variables (and local   
> > variables) even if the accessors are not defined, whereas in SELF   
> > there is an automatic definition of accessors.
> >
> > Crucial difference.
>
> Yes, it is that.
>
> If one decides only at compile time whether "self foo" is a message  
> send or a variable access, one must then recompile all methods  
that access
> the iVar foo as soon as an accessor is introduced.

Exactly!  The difference to now is that right now I'd have to  
manually modify the source code of all the methods doing access,  
whereas with the change the system can do the recompilation  
automagically.

I never suggested this was a panacea, just that it is a *little*  
better than what we have now.

>  A worse problem
> is what to do when an accessor is introduced **in a subclass**.
> Should that change the meaning of code in a superclass, or not?

Again, ask yourself what happens now.  There, you've got the initial  
answer.

> Worse, suppose the accessor does lazy initialization, but there are 
> references to the iVar where lazy initialization would be either
> incorrect or at least undesirable?

Then you shouldn't use the basic-accessor to do the lazy initialization.

Marcel





More information about the Squeak-dev mailing list