On Thu, Nov 26, 2009 at 5:06 PM, Graham Allan
<[email protected]>wrote:
> I know you asked for feedback through Artima, but I don't have an account
> and
> I wanted to share something.
>
> I enjoyed the article, however I think there's information missing that is
> likely to be useful. I've discussed with a few people the concept of
> functionality like this for Java, and inevitably they always ask, what if
> there's a conflict?
>
"the concept of functionality like this for Java"
Interesting, the number of times I've thought this to myself about different
features.
The answer is invariably that Scala already has it...
> So, by your example, what would happen if you had the following:
>
> trait A {
> def foo() = println("a.foo")
> def bar() = println("a.bar")
> def baz() = println("a.baz")
> }
>
> trait C {
> def foo() = println("c.foo")
> def bar() = println("c.bar")
> def baz() = println("c.baz")
> }
>
> class B(@proxy a : A, @proxy c : C) {
> def bar() = println("b.bar")
> }
>
> val a = new A
> val c = new C
> val b = new B(a,c)
> b.baz() // what happens here?
>
>
> Please excuse any poor syntax, I hope you get the idea.
>
> So personally, I would hope the Autoproxy plugin to report a compile error
> at
> the line:
> class B(@proxy a : A, @proxy c : C)
>
> ...and require that a conflicting method would have to be resolved by
> explicitly choosing one of the proxies to delegate to.
>
>
> But there's no mention of the policy for this in the article, which I think
> would be helpful, and from my experience is probably something that people
> will ask.
>
The current policy is that the first declaration wins.
So the final structure of B will contain:
All methods from B plus
All methods from A not matching any existing signature from B
All methods from C not matching any existing signature from A or B
This is actually by design, as B should be able to explicitly provide any
methods that would otherwise be delegated.
If the demand is there and this throws up problems for people, then I can
always emit a compiler warning for possible conflicts.
> HTH,
> Graham
>
> > New article on the plugin here:
> > http://www.artima.com/weblogs/viewpost.jsp?thread=275135
>
> --
>
> 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]<javaposse%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>
>
>
--
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.