April 19, 2004 Why must "only one" of a base function's precondition be satisfied? | ||||
---|---|---|---|---|
| ||||
From: http://www.digitalmars.com/d/dbc.html > In, Out and Inheritance > If a function in a derived class overrides a function in its super class, > then only one of the in contracts of the base functions must be satisified > Overriding functions then becomes a process of loosening the in contracts. In OOSC2 (P573) Meyer (who invented Design by Contract) says: > Assertion Redeclaration rule > A routine redeclreation may only replace the original precondition > by one equal or weaker, and the original postcondition by one equal or storgner. I am intersted to know why in D, "one of the in contracts of the base functions must be specified". Why must any of the "contracts of the base functions" be satisifed at all if the new precondition is satisfied. If an overriden function has a new precondition it should be or-ed with the existing preconditions. Is this the intention in D? Sam O'Connor |
May 26, 2004 Re: Why must "only one" of a base function's precondition be satisfied? | ||||
---|---|---|---|---|
| ||||
Posted in reply to samoconnor | <samoconnor@mac.com> wrote in message news:c600ck$203e$1@digitaldaemon.com... > From: http://www.digitalmars.com/d/dbc.html > > > In, Out and Inheritance > > If a function in a derived class overrides a function in its super class, > > then only one of the in contracts of the base functions must be satisified > > Overriding functions then becomes a process of loosening the in contracts. > > In OOSC2 (P573) Meyer (who invented Design by Contract) says: > > > Assertion Redeclaration rule > > A routine redeclreation may only replace the original precondition > > by one equal or weaker, and the original postcondition by one equal or storgner. > > I am intersted to know why in D, "one of the in contracts of the base functions > must > be specified". Why must any of the "contracts of the base functions" be > satisifed at > all if the new precondition is satisfied. > If an overriden function has a new precondition it should be or-ed with > the existing preconditions. Is this the intention in D? Yes, or-ing the preconditions is the same thing as stating that any of the preconditions need to be satisified, which is the same thing as what Meyer writes. |
Copyright © 1999-2021 by the D Language Foundation