reference to an interface
Jari-Matti Mäkelä
jmjmak at utu.fi.invalid
Tue Apr 11 12:59:11 PDT 2006
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 since I really appreciate the
work you've done with Mango.
--
Jari-Matti
More information about the Digitalmars-d-learn
mailing list