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

Re: Exegesis 4

Thread Previous | Thread Next
From:
Larry Wall
Date:
April 3, 2002 07:58
Subject:
Re: Exegesis 4
Message ID:
200204031557.HAA09529@wall.org
Mark J. Reed writes:
: 	<exegesis4>
: 	# Perl 5 code
: 	    for (my $i=0; 1; $i++) {
: 	
: 	which would translate into Perl 6 as:
: 	
: 	
: 	loop (my $i=0; 1; $i++) {
: 	</exegesis4>
: 
: May I infer from this the return of loop-scoped variables (in
: which the loop control variable is magically inserted into the
: loop block's lexical scope, even though it's declared outside of
: the latter's curlies)?  If so, I must have missed a mind-change in
: that thread; if not, then putting the 'my' inside the parens is a
: tad misleading . . .

No, the scope of $i stays outside, per the previous decision.  If you
want it inside you can always make $i an official formal parameter:

    for 0 .. Inf -> $i { ... }

I think that better documents a counted infinite loop in any case.

Larry

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