develooper Front page | perl.perl5.porters | Postings from July 2013

Re: [perl #109744] referenced constant loses readonlyness

Thread Previous | Thread Next
July 31, 2013 09:42
Re: [perl #109744] referenced constant loses readonlyness
Message ID:
Father Chrysostomos via RT wrote:
>If $a+$b returns a value, not a variable, then we could say that \ and
>for(...) and func(...) impose "variable context".

The usual term for this is "lvalue context".  A variable (that can vary)
is an lvalue.  A read-only scalar is also an lvalue.

It is instructive to compare against C.  The C equivalent of Perl's \
operator is &.  C's & operator requires that the operand be an lvalue
(but not necessarily mutable), and it is a compile-time error to apply
it to a non-lvalue.  Perl's pass-by-reference semantics would conflict
with any attempt to prevent enreferencement of non-lvalues.

Are you going to document \'s variable-generating semantics?


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About