Translating the loop at compile time into a new builtin foreach_idx sounds sensible, and it effectively automates what the programmer currently has do to in the code. But if $# is a lexical scoped at compile time to the for loop, it won't be available in subroutines called from the loop. This makes it inconsistent with next/last/redo, which do work from subroutines (matching the enclosing loop at run time). Personally speaking I'd be fine with that (I consider always allowing 'next' from a subroutine something of a wart on the language) but I just mention the asymmetry. One advantage of a new builtin loopidx rather than $# would be that you could specify loopidx(LABEL). This might be another point in favour of a compile-time translation approach, that it could allow loopidx(LABEL) to be implemented more easily. --- via perlbug: queue: perl5 status: open https://rt.perl.org/Ticket/Display.html?id=130038Thread Previous | Thread Next