Dan Sugalski writes: > At 1:21 PM -0600 6/14/04, Luke Palmer wrote: > >Dan Sugalski writes: > >> The slice vtable entry should take as its parameter a slice pmc. This > >> should be an array of typed from/to values, so we can do something > >> like: > >> > >> @foo[0..2,4..8,12..]; > >> > >> with three entries in the slice array--one with a from/to of 0/2, one > >> with 4/8, and one with 12/inf. > > > >Perl also has: > > > > @foo[0..12 :by(3)] # 0,3,6,9,12 > > > >PDL has affine slices. > > Yeah, but at some point you have to draw the line and say "This is as > far as we're going at the low level." > > >Iterators have the advantage over arrays since they can be infinite. > >With arrays, how do you represent: > > > > @foo[12... :by(3)] > > And that is probably well past it. :) > > >Do we still have multidimensional keys? > > Yes, we do.
Then these are both clear arguments for giving an iterator to slice rather than an array. We have no way to represent @foo[12... :by(3)], so how do we represent it? We have multidimensional keys but no way to slice by them. The former is solved by constructing the lazy iterator for C<12... :by(3)> and giving it to @foo's slice. The latter is solved by creating an iterator that yields multidimensional keys. What advantage does the simple array case give, other than the one fewer opcode from extracting the iterator? Luke