I found an old IRC discussion
<http://irclog.perlgeek.de/perl6/2012-02-02#i_5091684> where TimToday
specifically confirms that the `loop` construct doesn't get an exception to the
consistent scoping rules of `my` variables:
mikemol for(int foo; foo < n; ++foo) { /* some code */ } ; /* use
foo for something else; declaration from inside for() was
still active... */
TimToady mikemol: are you suggesting that's a bug? Perl 6 defines
loop that way to get consistent semantics; we only use ->
$foo to move external declarations into a blcok
mikemol TimToady: Yeah. Having declarations in the first part of a
for(;;) group imply that those declarations are tied to
that for(;;) statement. If a var needs to be survive the
for(;;) statement, it ought to declared prior to the
for(;;) statement. At least in languages which have strong
relationships with C and C++ syntax. And, at least, IMO.
It comes from seing things next to each other and expecting
them to be closely related. It makes inductive leaps about
behavior shorter.
TimToady well, Perl 5 went that route, and it turns into a complete
mess of built-ins doing one thing (sometimes) and
non-builtins doing something else
can't have that in an extensible language where built-ins
and non-built-ins are supposed to work the same
mikemol Sure.
Perhaps the for(;;) construct is simply misnamed in Perl 6.
TimToady it's called loop (;;)
and we very rarely use it
and when we do use it, it's often because we *want* the
loop variable to survive
drake01 TimToady: How does perl6 deal with the complete mess you
say?
TimToady my only ever declare a variable in the surrounding block
I'm closing this ticket accordingly.