Shortcut evaluation for hierarchy of in contracts
Walter Bright
newshound2 at digitalmars.com
Fri Jul 1 10:39:57 PDT 2011
On 7/1/2011 1:10 AM, Jens Mueller wrote:
> 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?
The loosening rule is that one of the in contracts must pass. That's exactly
what it does. As soon as one passes, there is no need to check the rest.
More information about the Digitalmars-d
mailing list