Sure, Scala has Traits. But the twist I am interested in is the
ability to modify the interface and not have to recompile the classes
that implement them.
Re. delegation. I already do this for multiple dispatch (https://
pec.dev.java.net/nonav/compile/javadoc/pec/compile/multipledispatch/
package-summary.html) but in that case I know the method signature in
advance. You could extend delegation techniques to any method but I
was hoping for something better.
On Dec 17, 9:07 am, "David MacIver" <[EMAIL PROTECTED]> wrote:
> On Dec 16, 2007 7:40 PM, hlovatt <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am interested in adding Traits to the Java language. Briefly Traits
>
> I think Scala might have beaten you to it... :-)
>
>
>
> > are like interfaces but you can have method bodies, but no
> > constructors or fields. If there is a conflict you have to resolve the
> > conflict:
>
> > interface X { int m() { return 1; } }
> > interface Y { int m() { return 2; } }
> > class XY implements X, Y { // conflict - 2 m methods
> > public int m() { return X.m(); } // resolve conflict - otherwise
> > error
> > }
>
> > More info. at:http://www.artima.com/weblogs/viewpost.jsp?thread=220916
>
> > This is easy (well if you call modifying the compiler easy) if you
> > force recompilation. However it would be an advantage to allow Traits
> > to be extended without recompilation since at present an interface is
> > in effect a fixed entity, e.g. change X:
>
> > interface X {
> > int m() { return 1; }
> > String s() { return "A"; }
> > }
>
> > Ideally you wouldn't want to have to recompile XY, instead it would be
> > nice if the class loader automatically added method s to XY (assuming
> > that XY didn't have an s already).
>
> > Does anyone have any wisdom they are willing to impart on the
> > practicality of writing a custom class loader or modifying *the* class
> > loader to achieve this?
>
> Would implementing this via delegation to static methods not be a much
> lighter way of achieving this? Essentially using the standard
> extension method hack of treating the first argument as 'this', but
> providing method bodies in the implementing classes which do that
> delegation, so they can be overridden properly, appear in the normal
> class hierarchy, etc.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM
Languages" 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/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---