Thoughts about in contract inheritance

Timon Gehr timon.gehr at gmx.ch
Wed Feb 29 12:45:19 PST 2012


On 02/29/2012 09:30 PM, Stewart Gordon wrote:
> 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.
>

OK.

>>> 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.
>

I think in this case the documentation has not been updated yet because 
the feature is still experimental. Anyway, even with the documentation, 
many essential parts of the language are documented only on this 
newsgroup or through the compiler implementation, unspecified completely 
or only partly specified. I don't think it is currently possible to 
become completely proficient in D without reading this newsgroup.


> <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.

An input that is not legal is illegal and vice-versa.


More information about the Digitalmars-d mailing list