Bumping. Let me emphasize this paragraph, which is really the crux of the problem:
> Put another way, the problem is that if I have an Associative which I > know maps integers to strings, and I invoke seq(), I don't know what > kind of values I'm going to get. Is this expected behavior or a bug? What's the appropriate place to submit bug reports? On Apr 13, 9:37 am, Dan <dansmit...@gmail.com> wrote: > I'm a Java developer; I work on a project that has adopted Clojure's > data structures as a convenient implementation of immutable sets, > maps, etc. In attempting to add type parameters to the Clojure > interfaces, I noticed a conflict in the definition of > IPersistentVector. I assume the problem exists when programming in > Clojure, too. > > IPersistentVector implements both Associative and IPersistentStack. > These, in turn, both implement Seqable. But the element type in the > two cases is different: if I have a vector of Strings, > IPersistentStack says that seq() should enumerate the strings; > Associative says that seq() should enumerate Map.Entries. The > APersistentVector implementation resolves this conflict by going with > the first: seq() gives you a list of strings. > > Put another way, the problem is that if I have an Associative which I > know maps integers to strings, and I invoke seq(), I don't know what > kind of values I'm going to get. > > When I say an interface "says" something, there's not actually much > documentation, so that's based on what I think is the natural > interpretation of the interface. The page at <http://clojure.org/ > data_structures> does say this about IPersistentMap: "seq returns a > sequence of map entries, which are key/value pairs." There is no such > assertion made about Associatives, but since IPersistentMap implements > Seqable through Associative, it would be odd to specify the contract > for Associative differently. > > It looks to me like the best way to handle this would be to eliminate > the connection between Associative and IPersistentCollection, leaving > that connection to the subtypes. But I don't know what kind of impact > that would have on existing code (if it breaks something, does that > code behave well when given an IPersistentVector?) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en