How about... something completely different? (Re: [squeak-dev]
Re: On traits composition)
cputney at wiresong.ca
Wed Dec 9 06:11:02 UTC 2009
On 8-Dec-09, at 2:24 PM, Göran Krampe wrote:
> 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
Lately, I've been thinking that it would be useful to have a
delegation operator. For the sake argument, let's use backtick, since
it's not used in Smalltalk. The operator could be applied to the
receiver in a message send, like this:
This would cause the #doSomething message to behave like a super send.
The selector #doSomething would be dispatched with respect to
anObject, but the method would be executed with the sender as the
I'm not sure what patterns of composition would emerge in a langauge
that supported it, but it seems like the simplest way to allow one
object to delegate to another object without inheriting from it.
More information about the Squeak-dev