Thoughts about in contract inheritance

Stewart Gordon smjg_1998 at yahoo.com
Wed Feb 29 12:30:59 PST 2012


On 29/02/2012 19:24, Timon Gehr wrote:
<snip>
> That was just for documentation... The part that is explicit is:
>
> // Single inheritance of state
> class ExtendedWidget : Widget {
> override void print(uint level)
> in { /* weakening precondition is okay */ } body {
> ... level may be 0 here ...
> }
> }
>
> The fact that this weakens the precondition tells us that it was not weakened before.

Of course.  I see now.

>> Besides, the interface declaration there isn't allowed by the grammar.
>
> The compiler implements it.

So what?  It's a bug that compiler behaviour doesn't match the documentation.  You seem to 
be agreed that this is the case with what happens to the contract where the override has 
no InStatement at all.

<snip>
>> So you consider illegal inputs to a function to be part of the API?
>
> Yes. Put differently, I consider legal inputs to a overridable virtual function to be part
> of the API.

That legal inputs are part of the API is something we're agreed on.  It's illegal inputs 
we were debating.

But I can see what you really mean: the spec of what inputs to an overridable function are 
legal and what inputs are illegal is part of the API.

Stewart.


More information about the Digitalmars-d mailing list