Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^10: Shouldn't references be readonly? (UPDATED)

by LanX (Cardinal)
on Aug 05, 2020 at 19:31 UTC ( #11120350=note: print w/replies, xml ) Need Help??


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

sure see Re^6: Shouldn't references be readonly?

DB<76> sub change { $_[0] = 666 } DB<77> $a=42 DB<78> change($a) DB<79> p $a 666 DB<80> change(42) Modification of a read-only value attempted at (eval 86)[c:/Perl_524/l +ib/perl5db.pl:737] line 2. DB<81>

still "lame"?

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

update

BUT!!!

DB<81> sub change_arr { $_[0] = [666] } DB<82> $a=[42] DB<83> change_arr($a) DB<84> x $a 0 ARRAY(0x3363180) 0 666 DB<85> change_arr([42]) #NO ERROR??? DB<86>

Replies are listed 'Best First'.
Re^11: Shouldn't references be readonly?
by jo37 (Friar) on Aug 05, 2020 at 19:48 UTC

    This is no answer to my question. My point is: however created, an alias is a reference to something put into a slot of a symbol table entry. I do not see any evidence in your examples against this claim.

    UPDATE And then again, a de-referenced reference should behave similar to an alias. AFAICS it does.

    Greetings,
    -jo

    $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
      > put into a slot of a symbol table entry.

      An alias is always a variable true, that's an obvious no-brainer.

      But typeglob mechanisms are only a part of the way to create them.

      Especially in for my $a (@a) { ... } there is no symbol table entry like you claimed. my $a is a private variable and an alias.

      And newer Perl versions allow activating the feature for refaliasing too, again no symbol table.

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

        Accepted.

        Greetings,
        -jo

        $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2020-12-02 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (41 votes). Check out past polls.

    Notices?