http://qs321.pair.com?node_id=11120335


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

Isn't an alias something dereferenced into a symbol table entry? So a reference and an alias are on different levels of indirection.

DB<1> use Scalar::Util 'readonly' DB<2> p readonly 1 134217728 DB<3> p readonly \1 0 DB<4> *one = \1 DB<5> p readonly $one 134217728 DB<6> $rone = \1 DB<7> p readonly $$rone 134217728 DB<8> $one = 2 Modification of a read-only value attempted at (eval 16)[/usr/share/pe +rl/5.20/perl5db.pl:732] line 2. DB<9> $$rone = 2 Modification of a read-only value attempted at (eval 17)[/usr/share/pe +rl/5.20/perl5db.pl:732] line 2.

Greetings,
-jo

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

Replies are listed 'Best First'.
Re^6: Shouldn't references be readonly?
by LanX (Saint) on Aug 05, 2020 at 18:20 UTC
    • alias

      A nickname for something, which behaves in all ways as though you’d used the original name instead of the nickname. Temporary aliases are implicitly created in the loop variable for foreach loops, in the $_ variable for map or grep operators, in $a and $b during sort’s comparison function, and in each element of @_ for the actual arguments of a subroutine call. Permanent aliases are explicitly created in packages by importing symbols or by assignment to typeglobs. Lexically scoped aliases for package variables are explicitly created by the our declaration.

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

      This a lame description of aliases. See Symbol Tables.

      Greetings,
      -jo

      $gryYup$d0ylprbpriprrYpkJl2xyl~rzg??P~5lp2hyl0p$
        Nope typeglobs are only one of many possibilities to have aliases.

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