develooper Front page | perl.perl6.language | Postings from April 2005

Re: Quickcheck of context of index expressions

Thread Previous
From:
Larry Wall
Date:
April 29, 2005 06:27
Subject:
Re: Quickcheck of context of index expressions
Message ID:
20050429132735.GB25663@wall.org
On Tue, Apr 26, 2005 at 03:56:37AM +0800, Autrijus Tang wrote:
: On Tue, Apr 26, 2005 at 03:33:44AM +0800, Autrijus Tang wrote:
: > Another quick check on expression context for indexed expressions.
: > Please sanity-check the return value of want() below:
: > 
: >     @x[0] = want();	# scalar context
: >     @x[want()] = $_;	# scalar context
: >     @x[want()] = @_;	# scalar context
: >     @x[0,] = want();	# list context
: >     @x[want(),] = $_; # list context
: >     @x[want(),] = @_; # list context
: >     $_ = @x[want()];	# scalar context
: >     @_ = @x[want()];	# list context
: 
: Oh, and under the S02 rules above (the index expression inherits
: outer context on RHS), Pugs currently does this:
: 
:     $_ = %x{ 1, 2 }   
: 	--- reduces to ---
: 	$_ = %x{ [1, 2] }
: 	    --- reduces to ---
: 	    $_ = %x{ "1 2" }
: 
: Which is, well, very surprising.  Where did I get wrong?

I think S02 is probably wrong.  It should be unknown/list context.

Sorry for the short answers, but I'm in Russia behind a flakey network
connection, which is probably going away entirely at any moment (the
network connection, not Russia.) I can clarify more next week when
I get back.

Larry

Thread Previous


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