Accessing variables through sending messages

Bryce Kampjes bryce at kampjes.demon.co.uk
Wed Jun 22 19:49:40 UTC 2005


Alexandre Bergel writes:
 > > This looks like premature static optimization for me. What's wrong with 
 > > just using messages? E.g., if all references to v1 and v2 are compiled 
 > > into message sends (something the compiler can do trivially [*]) you can 
 > > define the "offset" in any way you like in the leaf class (T3).
 > 
 > My first goal was to avoid having accessors to access variable. But you're right, this might probably be the way to go.

A decent way to make some selectors only accessible to local methods
would be another solution. I avoid accessors because they make it much
harder to find encapsulation, a better way to control encapsulation
would make accessors much less semantically offensive.

Theoretically, there is no performance cost to using accessors. If
access local to the object then they can be optimised away. If access
is not local then a type check or send is required.

Bryce



More information about the Squeak-dev mailing list