How about... something completely different? (Re: [squeak-dev] Re: On traits composition)

Igor Stasenko siguctua at gmail.com
Wed Dec 9 05:16:56 UTC 2009


2009/12/9 Göran Krampe <goran at krampe.se>:
> Hi all!
>
> Andreas Raab wrote:
>>
>> BTW, I really don't think there is much difference between mixins and
>> traits; all forms of MI are fairly equivalent.
>>
>> Cheers,
>>  - Andreas
>
> As most of us I was also very positive when Traits first came to the scene.
> Now, I am a lot more jaded and think "well, sure, but are they worth it?".
>
> Given Andreas' statement above - wouldn't it be *much* cooler to evolve
> Smalltalk along the axis of composition instead of the axis of inheritance?
>
> I have always thought that having better mechanisms for delegation would be
> awesome, and would in most ways be much more powerful than inheritance (in
> whichever form).
>
> For example, what if one could declare that for class Foo (having ivars x,
> y, z) any message that would result in a DNU would instead be "delegated" to
> ivar x (and then y if no lookup is found in x either).
>
> This would be equivalent to tons of messages in Foo like:
>
> Foo>>name
>        ^(x respondsTo: #name) ifTrue: [x name] ifFalse: [y name]
>
> (well, kinda, you get the picture - but also, taking care of x/y returning
> "self" in which case we probably should return the "Foo self" instead etc)
>

Hmm, how is it different to inheritance?
I mean, you can achieve similar effect by making
an instance of Foo class superclass to be x, and x superclass to be y.


> In many ways the mechanism I am describing is "built into" languages like
> self and Slate (I think).
>
> IMHO the above is very useful and would allow fine grained composition
> similar to Traits but in a dynamic more object centric fashion.
>
> regards, Göran
>
>
>



-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list