D - Why must "only one" of a base function's precondition be satisfied?
- samoconnor mac.com (10/17) Apr 19 2004 I am intersted to know why in D, "one of the in contracts of the base fu...
- Walter (10/26) May 26 2004 class,
From: http://www.digitalmars.com/d/dbc.htmlIn, 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
Apr 19 2004
<samoconnor mac.com> wrote in message news:c600ck$203e$1 digitaldaemon.com...From: http://www.digitalmars.com/d/dbc.htmlclass,In, Out and Inheritance If a function in a derived class overrides a function in its supersatisifiedthen only one of the in contracts of the base functions must becontracts.Overriding functions then becomes a process of loosening the inIn OOSC2 (P573) Meyer (who invented Design by Contract) says:storgner.Assertion Redeclaration rule A routine redeclreation may only replace the original precondition by one equal or weaker, and the original postcondition by one equal orI am intersted to know why in D, "one of the in contracts of the basefunctionsmust 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.
May 26 2004