Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, andwantarray() changes
[email protected] (Chaim Frenkel) 28 Aug 2000 18:09:26 -0400
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Message-ID | <[email protected]> |
What you want is a pre-condition on the overridden assignment operator. What you want to do may involve having the suggested transactional variables. <chaim> >>>>> "NT" == Nathan Torkington <[email protected]> writes: NT> Damian Conway writes: >> pre mymethod : group("safe-coding practice") { @_ > 0 } >> pre mymethod : group("debugging") { print @_, "\n"; } NT> Using these for lvalue subs doesn't give you the behaviour you want: NT> sub foo :lvalue { $foo } NT> post foo { die if $foo == 5 } NT> eval { NT> foo() = 5; NT> }; NT> Should not set the lvalue of foo to 5. But you can't test for NT> bad values until after you've made the assignment. -- Chaim Frenkel Nonlinear Knowledge, Inc. [email protected] +1-718-236-0183