Re: RFC 132 (v3) Subroutines should be able to return an lvalue
[email protected] (Nathan Wiger) Tue, 29 Aug 2000 16:49:11 -0700
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Organization | Sun Microsystems |
| Message-ID | <[email protected]> |
> One often heard argument is that subroutines like these must be > callable in either mode: > > lvsub(expr) > lvsub() = expr > > This argument is false, since the two uses are totally distinct. Yes and no. It depends on your application. I'm not shooting down the RFC at all, but this statement is not true in all cases. I've posted this about 1000 times but here's 1001: $cgi->param($var) = @val; $cgi->param($var, @val); It would be nice if these were the same sub, identically written, and Perl DWIM'ed. This is a powerful use of lvalue subs. Not the only one, but not one that should be shrugged off in favor of subs that can handle +=, &=, etc, but aren't flexible enough to do the simple thing listed above. Of course, I don't see why these RFC's can't all live together, that's why I wrote RFC 154, which tries to allow them to coexist. But I just wanted to clarify that point. -Nate