This one was actually implemented in Java but no one used it because
it wasn't at the language level presumably. Not sure if you knew
about it:
http://www.j2ee.me/j2se/1.4.2/docs/api/java/beans/Beans.html
Sam
As to #2, we weren't actually going to do it quite like that, but
rather we were going to have a disambiguation approach:
interface Bar {
void doStuff();
}
class Foo (delegate Bar bar, delegate Bar baz) {
}
This wouldn't compile, under our current thinking, because it's
ambiguous as to which delegate to delegate to. (I can't believe that
last bit of english is valid...)
Anyway, our current approach would do this:
class Foo (delegate Bar bar, delegate Bar baz) {
void doStuff() delegates to baz;
}
This is more important in cases of
interface Bar {
void doStuff();
void doBarStuff();
}
interface Baz {
void doStuff();
void doBazStuff();
}
where we doBarStuff() would obviously route to Bar, and doBazStuff()
to Baz, but the common signature is unclear. Currently, we force a
disambiguation as above. I think you're suggesting that the compiler
infer from the type, so we have less disambiguation to do. That's not
bad though, I sort of like the idea of a signature is a signature is a
signature, so if they share contract, you have to choose. I'm a
little worried about your approach creating more magic than the
programmer can process without tending to err, but maybe not. I'm
also somewhat polluted by my Objective-C background which cares more
about the method signature (in some senses) than the type. But this
isn't duck-typing, and it's a strongly typed language, so why not? I
have to mull this over.
As to #4, I was imagining something very much like an Objective-C
model, which has the "respondsTo" method, which simply asks if an
object can respond to a signature (Selector), with a companion
"invoke", so a call in noop if it adopted this sort of thing would
look like:
...
// @"foo" is a method selector, a signature primitive used for matching
if (myfoo.respondsTo(@"myMethod(Foo,Bar,Baz)")) {
myFoo.invoke(@"myMethod(Foo,Bar,Baz)",argz);
}
Selector being a first-class language element, the compiler would know
about it, and tools could properly do refactor operations on it, etc.
I haven't written this up as a proposal. Yours is similar, actually,
to another Objective-C construct which is overrding the invoke method,
to allow you to dispatch method calls how you will. I think among
these ideas is a sweet spot, but I haven't yet settled on it. I look
forward to your proposal on #4.
cheers,
Christian.