From: Jim Weirich Date: 2006-02-17T05:36:02+09:00 Subject: Re: OT: Is this worth a try? Logan Capaldo wrote: > class C < A > def meth(n) > precondition: n > 2 #Will not compile, C#meth accepts a narrower > range of inputs than A, does not follow Liskov Substitution Principle > end > end Actually, in Eiffel, this wouldn't be a compile error. Preconditions in a derived class is logically ORed with the those in the parent class. So that the full precondition for C#meth will be precondition: (n > 2) || (n > 1) Since the preconditions are ORed, they can only be widened in derivied classes. If you were using full Eiffel syntax, you would state derived class preconditions with "require else" rather than the plain "require" to help you remember that you can only widen the preconditions. Likewise postconditions in derived classes are ANDed with those in parent classes, so they can only be narrowed (and "ensure and" is used rather than the vanilla "ensure" [1]). -- -- Jim Weirich [1] Ensure in the Eiffel sense (defining preconditions) rather than ensure in the Ruby sense (finally blocks). -- Posted via http://www.ruby-forum.com/.