Accessing variables through sending messages

Bert Freudenberg bert at impara.de
Tue Jun 21 16:29:34 UTC 2005


Am 21.06.2005 um 16:29 schrieb Alexandre Bergel:

> Hello,
>
> I know there are some Self experts in this mailing list, that's why  
> I am asking a question related to it there. What would be the best  
> strategy to have variables not accessed by using their index, but  
> rather by sending messages correspondong to their accessors/mutators.
>
> I feel that an efficient implementation would require new bytecode,  
> therefore hardcoding this in the VM.
>
> Markus Denker has an implementation that use an object-as-compiled  
> trick to delay the recompilation of a method, but the assumption  
> was not to modify the VM.
>
> Anyone can confirm or infirm what I wrote ?

I'm not quite sure what you actually want to achieve ...

Tweak's compiler supports a variation of "implicit self", so "foo" is  
actually compiled into "self foo", but only if "foo" was declared as  
field (in contrast to Self, which uses implicit self universally).  
Fields are the Tweak-equivalent of an instance variable. Similarly,  
"foo := <expr>" is compiled as "self foo: (<expr>)".

So this compiler change lets you use entities looking like instance  
variables in the code that are actually referenced by message sends.  
Is that what you need?

- Bert -




More information about the Squeak-dev mailing list