Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The more I think about it the more I'm convinced that using lex-refs like in this post is the best KISS approach without using extra moduls.
$lamb=sub { my($x,$y)=\(@_); $$x += $$y } You just have to restrict referencing to arguments which are read/write and copying to read-only args. Such that $$x signals clearly "x is an alias" and $y "y is only a copy". $lamb=sub { my $x= \shift; my ($y)=@_; $$x += $y } Your code becomes much clearer and unintended changes to the original of $y are impossible, avoiding ugly and very hard to track bugs!!! Unfortunately its not possible to write this as dense (but more error-redundant) than in ruby...
But maybe I'm missing another "way to do it"? ( would be please to know 8) UPDATE: Of course you can use arraslices $a=sub { my($x,$y)=(\(@_[0]),@_[1]); $$x +=$y } or $a=sub { my($x,$y)=(\($_[0]),$_[1]); $$x +=$y }
link to footnotes within my own comment, so I'll just leave others to navigate manually. sure you can define anchor-names with a-tags and link to them with href to #name. E.g these KISSes are interlinked. Just look in the HTML-Source... But I doubt footnotes may help clarify your update-inferno... ;-)
Cheers Rolf In reply to Re: Local for lexicals
by LanX
|
|