>  From an old summary:
> 
> http://www.perl.com/pub/a/2003/04/p6pdigest/20030427.html?page=2
> 
>  > Paul Hodges took a crack at implementing for as a subroutine and came 
> up with
>  > something that didn't look too insane. Luke Palmer added a refinement 
> allowing
>  > for n at a time looping. However, for reasons that I can't quite put 
> my finger
>  > on, I'm not quite sure that either method has got the sub signature 
> quite
>  > right, and I'm not entirely sure how you would express for's 
> signature as a
>  > Perl 6 signature anyway. Answers on a mailing list please.
> 
> Did this ever get resolved to anyone's satisfaction?  While reading 
> EX6, I found myself wonder exactly what for() would look like in Perl 6 
> code...

Well, I don't think it's possible, actually.  There's a flattening
list context at the beginning (implying a sugary drink from 7 eleven),
followed by a code block.  But, as we know, slurpy arrays can only
come at the end of positional parameters.

But, assuming that is possible, here's C<for> in its entirety:

    sub for ([EMAIL PROTECTED], &block) {
        while @list {
            block( [EMAIL PROTECTED](0, &block.arity) );
        }
    }

That's not handling NEXT blocks, et al.  But I think that's just a
matter of putting &block.NEXT(), &c. in the appropriate places.

Luke

> -John

Reply via email to