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

Re: [perl #109744] referenced constant loses readonlyness

Thread Previous | Thread Next
From:
Zefram
Date:
July 31, 2013 09:42
Subject:
Re: [perl #109744] referenced constant loses readonlyness
Message ID:
20130731094205.GA24072@fysh.org
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?

-zefram

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About