Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes
[email protected] (Damian Conway) Mon, 28 Aug 2000 14:41:05 +1100 (EST)
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Message-ID | <[email protected]> |
> Damian Conway writes:
> > pre mymethod : group("safe-coding practice") { @_ > 0 }
> > pre mymethod : group("debugging") { print @_, "\n"; }
>
> Using these for lvalue subs doesn't give you the behaviour you want:
>
> sub foo :lvalue { $foo }
> post foo { die if $foo == 5 }
>
> eval {
> foo() = 5;
> };
>
> Should not set the lvalue of foo to 5. But you can't test for
> bad values until after you've made the assignment.
Postconditions on lvalue subs are not tested until the end of the complete
expression in which the sub is called.
Damian