develooper Front page | perl.perl5.porters | Postings from August 2009

Re: A complete design for := (bind)

Thread Previous | Thread Next
August 21, 2009 10:20
Re: A complete design for := (bind)
Message ID:
Daniel Ruoso wrote:
>In Perl 5 that stores a Scalar value of 1 in the glob "a" of the current
>In Perl 6, on the other hand, that stores a Scalar object in the entry
>"$a" of the lexpad and stores the Integer 1 inside it's "cell".

Actually Perl 5 does have a distinction of this nature.  A p5 scalar
can be read-only, and the scalar slot in a glob can be made to point at
a read-only scalar.  Like this:

$ perl -lwe '*x = \1; print $x; $x = 2; print $x'
Modification of a read-only value attempted at -e line 1.

Contrast with the writable equivalent:

$ perl -lwe '*x = \(my$y=1); print $x; $x = 2; print $x' 

I would expect to be able to do either of these with the := operator,
with some form of $x on the LHS.


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