> If someone has a better idea I'd love to hear it.
I don't proclaim that, but I have a suggestion.
This seems to be such a similar idea to traits* that it may be worth making
the leap to them if you consider them to be more powerful. One thing with the
delegates idea is that they don't allow 'bolting on' the behaviour if you
don't have access to the source file (correct me if I'm wrong).
An example of this could be the mixin demonstrated by the java-mixins creator:
MyObject myObject = new MyObject() {
@With(interface = MutableTreeNode.class,
implementation = MutableTreeNodeTrait.class)
}
Would make MyObject implement MutableTreeNode and have an implementations
methods bolted in. Of course, there's drawbacks to this that aren't there
with @Delegate: the new class created by the above example has the
performance disadvantages of being compiled to a new class. @Delegates can
also have state, which could be beneficial.
May be off-target with some of these comments: I'm sure you'll let me know ;-)
But the @Delegate description sounds really good.**
* maybe not in Scala, I'm not familiar with exactly how they work.
** I have thought how it would be useful before:
http://stackoverflow.com/questions/254276/would-syntax-for-composition-be-a-useful-addition-to-java
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "The
Java Posse" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaposse?hl=en
-~----------~----~----~----~------~----~------~--~---