Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
The stupid question is the question not asked
 
PerlMonks  

Re: ref to read-only alias ... why?

by LanX (Abbot)
on Jan 05, 2012 at 23:27 UTC ( #946494=note: print w/ replies, xml ) Need Help??


in reply to ref to read-only alias ... why?

Interesting ...

It appears like read-only values are not modified when aliased.

DB<123> sub tst { my $r = \ $_[0]; print ++$$r; } DB<124> $x=3; for (1,2,$x) { tst($_); print ": ",$_,"\n" } 2: 1 3: 2 4: 4

UPDATE:

Seems to me like "aliasing" read-only values is falling back to "copying".

Or in other words: Only lvalues can be "really" aliased.

Which makes sense in a way, because the original value can't be changed anyway.

Cheers Rolf


Comment on Re: ref to read-only alias ... why?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://946494]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (10)
As of 2014-04-16 21:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (434 votes), past polls