April 11, 2006 Re: reference to an interface | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jari-Matti Mäkelä | Jari-Matti Mäkelä wrote: > kris wrote: > >>Jari-Matti Mäkelä wrote: >> >>>kris wrote: >>> >>> >>>>Frank Benoit wrote: >>>> >>>> >>>>>An interface is something like a promise. A class implementing an >>>>>interface promises to have all these methods. Your class C2 is >>>>>overriding the method from C1 that's all. Your two "help" methods are >>>>>not two different one, they are the same. >>>>> >>>>>C2 promises twice to implement a methods "void help();", inherants the >>>>>one from C1 and overrides it. >>>> >>>>That's a really good analogy/description ... >>> >>> >>>Indeed. But when will it promise to sort things too (== when will it >>>really treat instances of an interface as objects) ;) >>> >>>#interface comparable { >>># int opCmp(Object o); >>>#} >>># >>>#class item : comparable { >>># int opCmp(Object o) { return 1; } >>>#} >>># >>>#void main() { >>># comparable[] c; // compiler/lang spec "problem" here >>># c ~= new item; >>># c ~= new item; >>># c ~= new item; >>># >>># c.sort; // segfaults here >>>#} >>> >>> >> >> >>That's an implementation issue. D had a long and sordid history in this >>regard ~ I used to be one of the primary antagonists, but gave up long ago > > > Well, for me it's the only real problem in D. I can live with imports > "polluting" namespaces now, but really hope that someday (in the not too > distant future) D will correctly support interfaces. Walter already > implemented that covariance part of interfaces, so there's much less to > implement now (at least Walter admitted that some work needs to be done ;) > Hope you still like the other aspects of D D always held immense promise. > since I really appreciate the > work you've done with Mango. I'm but one part of that project, but thank you, and you're welcome! |
April 13, 2006 Re: reference to an interface | ||||
---|---|---|---|---|
| ||||
Posted in reply to Chris Nicholson-Sauls | In article <e1eeql$e2o$1@digitaldaemon.com>, Chris Nicholson-Sauls says... > >Quite actually, as I believe we have return type covariance for interfaces, you can in fact define the factory method in the interface. Yes, but the defintion is useless until the class implementing the interface is instantiated. That counters the notion of a factory reachable through the interface. I have to revert to a simple "new", but then I do not need any factory? |
Copyright © 1999-2021 by the D Language Foundation