On Thu, 3 Oct 2002 18:46:14 -0400, Michael G Schwern wrote: > method foo($this, $that) is memoized is something > is pre { $this <= 42 } > is pre { $that == $this / 2 } > is pre { now we have a little bit more room to play with using > a differnt indentation style } > is post { but post conditions are still distanced from the > code which return()s } > { > ... > } > > I realize that conditions are technically part of the signature, but putting > them in there paints us into a stylistic corner.
This is the one nice thing about the Pascal-like syntax of Eiffel. It allows this situation to be unambiguous and sensibly ordered (as well as giving each condition labels, so that violations can be better reported): foo(this: ThisType, that: ThatType): FooType IS REQUIRE small: this <= 42 half: that = this / 2 DO -- implementation goes here ENSURE fooed_ok: RESULT = baz(this) + that END If you're declaring an abstract feature, just replace the whole DO clause with "DEFERRED". Also notice how Eiffel's syntax also somehow makes statement terminators completely optional. Aren't sub declarations in Perl 6 all expressions? Why couldn't we put the post condition at the end, then? sub foo($this, $that) is memoized is something is pre{ $this <= 42 } is pre{ $that == $this / 2 } { # implementation goes here } is post{ # postcondition 1 } is post{ # postcondition 2 } If you want an abstract method, just omit the implementation block. -- Peter Haworth [EMAIL PROTECTED] "Maybe that's [Java's] niche, its a language for people who like pain." -- Dean Wilson