4 ms·
It’s a compromise between structural and nominal typing to boost code reuse without locking yourself prematurely into structural typing. It’s been tried before
by hinkley 8y ago
It’s a compromise between structural and nominal typing to boost code reuse without locking yourself prematurely into structural typing. It’s been tried before and has been given different names.
Personally I’m fond of it. It’s one of several ways to blur the line between “is a” and “has a” relationships. We used to go out of our way to distinguish the two (eg in UML) but it has fallen out of favor.
A coworker long ago convinced me that improvements to delegation would be coming soon to new languages and unfortunately this is one of the first times I’ve seen it happen close to the way he hoped.
- sitkack 8y agoDelegation is extremely powerful, but it is easily implementable in most OO and Functional languages, no?
- lmm 8y agoIf you have to implement it by hand you end up not doing it, especially in languages where "extends" is right there.
- pjmlp 8y agoKotlin and Groovy are two languages where you get direct support for delegation.
- didibus 8y agoWhat do you mean by delegation?