Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^9: Shouldn't references be readonly? (updated)

by dave_the_m (Monsignor)
on Aug 06, 2020 at 08:51 UTC ( #11120408=note: print w/replies, xml ) Need Help??


in reply to Re^8: Shouldn't references be readonly? (updated)
in thread Shouldn't LITERAL references be readonly? (updated)

print \1; # SCALAR(0xdf00e0) print \1; # SCALAR(0xdef540)

I don't understand what of interest that's supposed to show. The first line has a compile-time literal value 1, and a run-time operator, \. The second line has another literal and op. Whether the two literals resolve to the same SV internally is entirely down to how the compiler optimises things. As it happens perl doesn't look for common shared constants.

(Also as it happens, \1 is constant-folded at compile time, in the same way that 1+2 is.)

Replies are listed 'Best First'.
Re^10: Shouldn't references be readonly? (updated)
by LanX (Cardinal) on Aug 06, 2020 at 12:26 UTC
    > I don't understand what of interest that's supposed to show.

    The fact that [...] resolves each time to a new AV was used as argument against being literal.

    Obviously most "literals" are not treated the way constants are. (with the exception of undef)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2020-10-20 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (208 votes). Check out past polls.

    Notices?