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

Is Aggregate Reference Topicalization Reliable for given?

Thread Next
From:
chromatic
Date:
July 23, 2009 15:04
Subject:
Is Aggregate Reference Topicalization Reliable for given?
Message ID:
200907231503.57834.chromatic@wgz.org
I'm writing about given/when.  I tried this snippet with Perl 5.10.0 and 
bleadperl:

	use 5.010;

	my @args = 1 .. 3;

	given (@args)
	{
	    say;
	    $_->[0] = 2;
	    say;
	}

	say @args;

(You can see similar behavior with hashes).

This only occurs with implicit topicalization -- assignment to $_ , as 
explicit assignment behaves as expected.

Is this a deliberate feature?  Is it an accident of implementation?  Is it 
desirable behavior?  Is it documented behavior (I could not find such 
documentation)?  Should it be documented as undefined, unreliable behavior?

-- c

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