Re: optional feature with contract inheritance? (design question)

2010-02-27 Thread Jonathan M Davis
Lutger wrote: > Jonathan M Davis wrote: > >> Lutger wrote: >> >>> >>> True, it only adds AssertError and that could be replaced with regular >>> asserts. >>> >>> Thanks. >> >> ??? Regular asserts? When asserts in D fail, they throw an exception of >> type AssertError. So, unless you're talkin

Re: optional feature with contract inheritance? (design question)

2010-02-27 Thread Lutger
Jonathan M Davis wrote: > Lutger wrote: > >> >> True, it only adds AssertError and that could be replaced with regular >> asserts. >> >> Thanks. > > ??? Regular asserts? When asserts in D fail, they throw an exception of > type AssertError. So, unless you're talking about explicitly throwing a

Re: optional feature with contract inheritance? (design question)

2010-02-27 Thread Jonathan M Davis
Lutger wrote: > > True, it only adds AssertError and that could be replaced with regular > asserts. > > Thanks. ??? Regular asserts? When asserts in D fail, they throw an exception of type AssertError. So, unless you're talking about explicitly throwing an AssertError yourself (which seems ra

Re: optional feature with contract inheritance? (design question)

2010-02-27 Thread Lutger
Jonathan M Davis wrote: ... > > Generally, I speaking, I think that having functions which override > functions from a base class and throw if they're used is a bad design. It > may be that it makes perfect sense in some contexts, but generally, I'd > consider it a very bad idea. Personally, I hat

Re: optional feature with contract inheritance? (design question)

2010-02-27 Thread Jonathan M Davis
Lutger wrote: > What do you think of the following use of contracts? > > class Base > { > void useFeatureA() > in { assert(false, "Base does not implement feature A"); } > body > { > /* throw here? */ > } > > bool hasFeatureA() > { > return false; >

optional feature with contract inheritance? (design question)

2010-02-27 Thread Lutger
What do you think of the following use of contracts? class Base { void useFeatureA() in { assert(false, "Base does not implement feature A"); } body { /* throw here? */ } bool hasFeatureA() { return false; } } class Derived : Base { override