So Map is Iterable, but Sequence is not? I would have thought that it should rather be the other way around.
I can understand calling values() or keys() to retrieve something Iterable on a Map, because iterating over a Map is a little confusing - what am I iterating over - keys? values? key/value entries? Whereas iterating over a Sequence is clear and un-ambiguous. If Sequence is not going to be Iterable, perhaps we need another type in the heirarchy that is Iterable, so that those places in pivot.wtk which use Sequence in the API are easier to work with. I nomitate IterableSequence, which is perhaps a little unwieldly, but reasonably obvious :-) On Sun, Apr 12, 2009 at 19:14, Todd Volkert <[email protected]> wrote: > Greg can correct me if I'm wrong, but I believe it's to allow us to > combine collections in ways that aren't possible in the JDK > collections, like: > > class Foo implements Map<A, B>, Sequence<C> > > If Sequence (and Dictionary) extended Iterable, this type of class > would be impossible. > > -T > > On Sun, Apr 12, 2009 at 10:14 AM, Noel Grandin <[email protected]> wrote: >> Hi >> >> I was quite surprised when I called a method on a widget that returns >> a sequence, and could not iterate over the Sequence<T>. >> >> Is there a reason that Sequence<T> does not extend Iterable<T> - it >> seems like most of the subclasses that implement Sequence do this >> anyhow, and it would certainly make using it more convenient. >> >> Regards, Noel Grandin. >> >
