in reply to Local for lexicals
$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...
$lamb=sub { my ($$x,$y)=@_; $$x += $y } # Can't declare scalar dereference in "my"
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
|
|---|