The Non-Virtual Interface idiom in D
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Sun Sep 27 06:53:12 PDT 2009
Michel Fortin wrote:
> On 2009-09-26 10:06:24 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> said:
>
>> Michel Fortin wrote:
>>> I think you're writing a lot of boilerplate code for something that
>>> the compiler should be able to do by itself. I mean, it's a lot
>>> cleaner with contracts, and there is no reason the compiler couldn't
>>> generate itself that "contract-verifying" non-virtual function.
>>
>> I think it would be a mistake to latch on my quick examples. It's not
>> only about before and after checks, it's more about low-level
>> customization points versus higher-level interfaces.
>
> Then your examples should have shown this instead.
Herb's article has them!
> I fully support having a way to specify a default implementation for a
> function in an interface. It might get handy for a few things (like
> implementing the delegate pattern you see everywhere in Cocoa). But it's
> a bad replacement for contracts.
Walter has implemented contract inheritance, and we hope to be able to
have contracts on interfaces in too. The former is a nice expected
feature; the latter could convince DbC skeptics to start using it.
Andrei
More information about the Digitalmars-d
mailing list