I think juerd has posted a number of examples of where such behaviour would be very useful indeed. Hopefully he will reply with a link.
Just think of anything you can do with a variable, but cannot do with a value returned by a sub.
Variables are really powerful in Perl because they are mutable. While other languages disagree that this is a good thing (Python, for example, has immutable variables - only assignment can change a value), we should stick to the Perl idea that this can actually be put to great use.
Variables are variable, and that's where they excel. Some examples of what you can do on lvalues, but not on rvalues:
But really, my favourite:To extend it to Perl 6, I'll explain how "." and ".=" work in P6: "." is used for method calls and dereferencing, as with "->" in Perl 5. ".=" is like Perl 5's ".=", except "." doesn't concatenate strings. If this is too vague, let one example be sufficient to explain what I mean: @array.=sort; does the same as @array = @array.sort, but possibly more efficient. No more need for LHS detection hacks like with the optimization for @array = sort @array; in Perl 5.
The expressiveness, flexibility and efficiency of lvalue operations must not be undersestimated.
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
In reply to Re^9: Experimenting with Lvalue Subs
by Juerd
in thread Experimenting with Lvalue Subs
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |