]- I can't remember but i think I read somewhere or it was discussed here (can't
]remember), but I think it was mentioned that Perl6 will have PRE and POST method/sub
]handlers probably specified as attribute, so that (syntax may be wrong):
class XXX {
method blah is PRE {}
method blah {}
method blah is POST {}
}
is ok.. not sure about the FALSE-condition that prohnobit the blah-method-call ?
One more thing I was wondering would it be possible to define a method/sub with
different signatures but with the same name ? ( i think yes, ?Class::Multimethods?!
was doing that aren't it ?)
raptor
PS. One thing just pooped to me... is the "class { }" a block so that we can do all
block mumbo-jumbo with it :")
|> What I've often wanted would be standard method that is called before
|> every
|> subroutine call. If that method returns false then the method that was
|> called is not called.
|
|I think maybe what you're looking for is another Eiffel/Sather-ism. I
|know Eiffel at least has both pre and post-conditions that look
|something like this(it's been a while, so if this isn't quite right):
|
|class
| ACCOUNT
|creation
| make_with_balance
|feature { BANK }
| balance: INTEGER
| make_with_balance(initial_balance: INTEGER) is
| require
| initial_balance >= 0
| do
| balance := initial_balance
| ensure
| balance >= 0
| end
|end
|
|I too have thought this might be useful in Perl6. Perhaps...
|
|class Account {
| my INT $balance;
| method new(INT $initial_balance //= 0) {
| REQUIRE { $initial_balance >= 0; }
| $.balance = $initial_balance;
| ENSURE { $.balance >= 0; }
| }
|}
|
|