Hi all,

I have just one syntatic wish for Apoc4 (which in all other points I 
find utterly fantastic).

Could we have:

 foreach $item in @arr {...}

Instead of

 foreach @arr -> $item {...}

I find the first one:

    - Much more pleasent to the eyes and less noisy on a long program.
    - Easier for the newcomer to get the meaning.
    - More similar to perl5's  foreach $item (@arr), since at least we 
preserve the order.

The multi-array foreaching could become:

 foreach $item; $other in @arr; @otherarr {...} # as in Apoc4

Or maybe

 foreach $item in @arr; $other in @otherarr {...}

On a totally different level of foreaching:

¿are we going to have a iterator protocol? I am talking of python's 
iterators, not ruby ones (which are being discussed in a different 
post). The iterator protocol allows any object that implements a .next 
method to be used in a foreach loop. This is very handy for things like 
filehandles, recordsets, generators, coroutines and nearly any data 
structure you can imagine.

For example, filehandles can implent the iterator protocol out of the 
box, so you can write:

 foreach $line in $fh {print $line}

Or maybe:

 foreach $line in $fh.lines {print $line}

Where $fh.lines is an object that implements the iterator protocol, not 
an array of the lines (and thus much more efficient).

There was something about this in Apoc2, but I didn't get a clear 
concolusion of it. The are a lot of useful applications of python-like 
iterators, and perl6 is doing a great job of taking the coolest things 
of other languages and integrating them into a choerent design, so i do 
have a hope. [:)]

This is of course related to Ruby's iterators, that take a somehow 
opposite solution to solve a similar problem.

---------------------
Angel Faus
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>

Reply via email to