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

Re: A complete design for := (bind)

Thread Previous | Thread Next
From:
Zefram
Date:
August 21, 2009 10:20
Subject:
Re: A complete design for := (bind)
Message ID:
20090821172038.GC23410@fysh.org
Daniel Ruoso wrote:
>In Perl 5 that stores a Scalar value of 1 in the glob "a" of the current
>lexpad.
>
>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'
1
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' 
1
2

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

-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