Eliminating assignments and variable syntax (accessors)

Marcel Weiher marcel at system.de
Mon Aug 2 22:06:26 UTC 1999


> From: Stefan Matthias Aust <sma at netsurf.de>
> Resent-Sender: squeak-request at cs.uiuc.edu

> I don't care whether the compiler uses direct slot access or accessor 
> methods to set and get values but I don't want to see that  
implementation
> detail on the language level.

Funny, that was *exactly* the idea of my proposal.

You *always* use "message" syntax to access slots, though that  
message syntax is modified slightly in order to have less typing and  
integrate local-vars.  You could just as well use full message-send  
syntax for this, though I would find that a little verbose.

> Actually I like the way Python deal with this.  Python has a  
number of low
> level methods you can overwrite to change the behavior of default
> operations like + or - but also for things like assignments, slot  
access or
> indexed access.  I think this is only reason why Python is generally 
> considered as very easy to learn.  As a beginner you don't have to deal 
> with these implementation issues but as an expert, you can access  
the meta
> level.
>
> >Prepending 'thisContext' to the lookup chain for implied messages   
> >brings arguments and local variables into the game, at least
> >conceptually (though of course a normal context won't respond to   
> >these messages).
>
> Why not?  This is how SELF works.

Because I don't want to go the SELF way, but rather make an  
absolutely minimal change.

> >Variables can be kept somewhat
> >private by not creating accessors for them.  Decisions to use direct   
> >variable access are localized, not spread over all the code that   
> >makes use of the variable.
>
> I don't understand the last point?  How can you restrict the  
access by not
> providing accessor methods if this would also mean that nobody can  
access
> them. As I understood, you wanted to get rid of ":=" and direct  
variable
> access altogether.  Without (public-accessable) methods you cannot use 
> these variables...

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.

Marcel





More information about the Squeak-dev mailing list