Shortcut evaluation for hierarchy of in contracts

Jens Mueller jens.k.mueller at gmx.de
Fri Jul 1 01:10:34 PDT 2011


Walter Bright wrote:
> On 6/30/2011 3:42 AM, Jens Mueller wrote:
> >The shortcut evaluation is specified in TDPL. That's why I assume the
> >behavior is intended.
> 
> The behavior is both intended and crucial to the notion of contract inheritance.
> 
> The 'in' contract must pass at least one of the 'in' contracts of
> its inheritance hierarchy.
> Derived functions "loosen" the requirements for input.

Yes. But the problem with passing only one of the in contracts is that
it is error-prone because it *assumes* that for in contracts the
requirements are widened. But what if the programmer fails at loosening
a derived in contract, i.e. he restricted it. In the current setting the
programmer won't know that he did an error. And with deep inheritance
hierarchies it gets more complicated to have all the contracts of super
classes in mind.
Why not check all in contracts to make sure that they follow the
loosening rule? Why not enforce the loosing rule?

Jens


More information about the Digitalmars-d mailing list