in reply to RFC: Sub::Attributes -- alter subroutine context behavior with attributes

I don't know that the iterator object is useful.

I think it'll be useful as a "do this later" kind of thing. In other words, a programer wants to provide an iterator, but they just want to get something working right now. So they return an array and put the iterator attribute on the subroutine, intending to create a more efficient implementation later.

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated

  • Comment on Re: RFC: Sub::Attributes -- alter subroutine context behavior with attributes
  • Download Code

Replies are listed 'Best First'.
Re: Re: RFC: Sub::Attributes -- alter subroutine context behavior with attributes
by diotalevi (Canon) on Dec 10, 2003 at 15:40 UTC
    No its not. That marries the code to Ovid's idea of what an iterator's API looks like. If I wrote it I'd have returned a sub reference and called it as $result->() and avoided the whole 'next' thing altogether.

      *shrug* Personally, I think it should return a Class::Iterator object (which provides iterator versions of map and grep), though that marries you to Robert Silve's idea of what an iterator API looks like.

      ----
      I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
      -- Schemer

      : () { :|:& };:

      Note: All code is untested, unless otherwise stated