On Fri, 4 Oct 2002, Peter Haworth wrote:
: 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".
That is exactly what a literal C< {...} > means in Perl 6, and why it's required on
forward declarations of
anything that takes a block, if you really mean it that way. You can't say
sub foo;
in Perl 6. You have to say
sub foo {...}
: Also notice how Eiffel's syntax also somehow makes statement
: terminators completely optional.
Yes, well, let's not go there... :-)
: 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.
The absence of something is hard to notice. Put {...} for an abstract method.
Larry