Re: RFC 154 (v1) Simple assignment lvalue subs should be on by default
[email protected] (Chaim Frenkel) 25 Aug 2000 14:11:53 -0400
| Newsgroups | perl.perl6.language.subs |
|---|---|
| Message-ID | <[email protected]> |
>>>>> "NW" == Nathan Wiger <[email protected]> writes: NW> If arrays are maintained "properly" (not flattened) in Perl, then they NW> will remain separate, whether as parameters, across = assignments, etc, NW> etc. The same goes true for mixing arrays and scalars and hashes: NW> @stuff = docoolstuff(%hash, $var, @array); NW> @stuff = docoolstuff(%hash, $var) = @array; Then assignment arguments must be a the tail of the prototype. A bit of limitation. If you do want to persue this, and it is acceptable it should come in on a non-calling parameter. A seperate communication channel. Hmm, your proposal also make a non-lvaluable subroutine lvaluable. With arbitrary values. sub foo { launch_missles if $_[0] } foo = 35; The current thinking in -internals is that @_ will continue to flatten the arguments. So any rvalues being pushed in will be lost. >> By limiting it to only the programmer specified arguments, you reduce >> complexity with no loss of generality. NW> You do lose the ability to chain subs together, which is neat. For NW> example, using a sub a middle value to a split(): NW> @user = ($uid, $x, $p->format) = split /:/, <PASSWD>; This sounds like a valid reason. But again if a seperate channel is provided then it is much clearer what is going on. But if tieing were made simpler then this could be done (with a little more syntax. tie $magic, (something to do with $p->format) @user = ($uid, $x, $magic) = split /:/, <PASSWD>; Or perhaps something along the lines of ksh's <() syntax? @user = ($uid, $x, >($p->format)) = ... <chaim> -- Chaim Frenkel Nonlinear Knowledge, Inc. [email protected] +1-718-236-0183