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


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

Source?

Source is perlref: (I misremembered slightly)

Anonymous hash and array composers like these can be intermixed freely to produce as complicated a structure as you want. The multidimensional syntax described below works for these too. The values above are literals, but variables and expressions would work just as well, because assignment operators in Perl (even within local() or my()) are executable statements, not compile-time declarations.
  • Comment on Re^5: Shouldn't references be readonly?

Replies are listed 'Best First'.
Re^6: Shouldn't references be readonly?
by LanX (Cardinal) on Aug 05, 2020 at 22:11 UTC
    you are aware that "constructor" isn't even mentioned in your definition? ;)

    calling [$a] a "literal constructor" is not far fetched.

    a non literal construction is in contrast to do { @a=($a); \@a } because it involves a variable.

    This it meets the definitions in perlglossary ("no variable") and is also mirrored in JS terminology which has 100% the same semantic.

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

      you are aware that "constructor" isn't even mentioned in your definition? ;)

      Yes, that is what I misremembered: perlref calls them "composers" but they act just like constructors. :-)

      Calling it a "constructor" is a hint that it does something at runtime, instead of being a literal embedded into the program text. That its return value is mutable should not be a surprise.