I can see the point of having each list element of a slice being an
iterator rather than a set of discreet start/end pairs. That'd be
handy in some cases, and avoid having the perl 6 compiler having to
construct iterators by hand rather with slices. (On the other hand,
I'm perfectly fine with that, too)
So, given that, should plain scalars act as iterators holding a
single value and implement the iterator protocol? That'd make slice
implementation easier, but there's that whole nasty complexity thing
there. (Though without it there's the issue of complexity
elsewhere--no real win here, just a matter of deciding where to lose
less)
--
Dan
--------------------------------------it's like this-------------------
Dan Sugalski even samurai
d...@sidhe.org have teddy bears and even
teddy bears get drunk
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