Re: RFC 118 (v1) lvalue subs: parameters, explicit assignment, and wantarray() changes
[email protected] (Nathan Wiger) Thu, 17 Aug 2000 09:21:34 -0700
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Message-ID | <[email protected]> |
Andy Wardley wrote: > > I'm inclined to say that assignments of the form: > > $foo->bar(@baz) = @boz; > > Are allowed, but just plain stupid. It's the same as: > > $foo->bar(@baz, @boz) > > and you're right, Perl can't tell the lvalues and rvalues apart. So > don't do that. I hate to add a "me too" but I think this is right on. I also think that Nat's proposal and several other discussions overlook some stuff about lvalue subs. Most of the places I've seen them used really well is if they walk and talk like other forms: $cgi->param($var, @val); # traditional $cgi->param($var) = @val; # lvalue, but same thing The second one, then, just makes it more obvious what's going on. But it shouldn't change the behavior of the sub. In fact, these two should *both* be valid options for setting $var. Then the programmer can choose their preferred style. -Nate