The Non-Virtual Interface idiom in D
Michel Fortin
michel.fortin at michelf.com
Sun Sep 27 06:00:52 PDT 2009
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.
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.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list