in reply to Re^8: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
in thread use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20

it'd be nice to have some sort of iteration interface so that we could use for against a collection or generator or iterator or array without having to flatten the values into a list.

Um, neither for my $item ( @array ) { ... } nor ... for @array; flatten?

And for hashes, use ... while (key, value) = each %hash;


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^10: use feature 'postderef'; # Postfix Dereference Syntax is coming in 5.20
by chromatic (Archbishop) on Nov 25, 2013 at 21:42 UTC

    Sure, Perl has special ops for non-flattening iteration of arrays and hashes, but it doesn't have an iteration interface so you can't write your own non-flattening iterator.

      I guess I am still misunderstanding you because it quite easy and very common to use a sub ref closing over a counter as an iterator for use with while. By way of example, see Algorithm::Combinatorics

      I'm not seeing the difficulty you are alluding to, so perhaps you could clarify for me?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.