Michael G Schwern   <[EMAIL PROTECTED]> wrote:

> I can see too many problems with that technique, I think one was
> already mentioned where subclasses can unintentionally weaken
> preconditions to the point of eliminating them. 

Which is, of course, why we OR them, yet AND the postconditions

It is perfectly valid for an implementation to say "I can meet the
post-condition, no matter what input you give me" i.e. it can
eliminate the precondition, but not the postcondition. As code:


  class Math is interface {
    method sqrt (int $x) {
      PRE { $x >= 0 }
      POST { sqrt($x) * sqrt($x) == $x }
    }
  }

  class KnowsAboutComplex is Math
  {
    method sqrt (int $x) {
      PRE { TRUE }
      # calc result, possibly complex
    }
  }

Of course, KnowsAboutComplex would be invalid if the
interface had required the result to be a Real.


Dave.

Reply via email to