On Tue, 15 Jun 2004, Dan Sugalski wrote:
> So, given that, should plain scalars act as iterators holding a single
> value and implement the iterator protocol?

That'd be messy if two things tried to take an iterator over the same scalar
as the same time. On the other hand if it created an iterator as a separate
PMC then can see that would save having to construct an anonymous singleton
array, and then an iterator over that.

I would envisage that when the Perl6 compiler sees

   @foo[2, 3..7 :by(2), 11, 13, 17]

it would create four iterators: one each over [2], [3..7:/2] and [11,13,17],
and a concatenation iterator over those. Whether the iterator over [2] is
created over a singleton array or directly from the scalar would seem to be
simply a matter of economy.

-Martin


Reply via email to