I've got a bit of code implementing Associative, in order to provide a
fake map that responds to all calls to valAt with the same object, no
matter what the key is.

Since it therefore "contains" every possible key, it doesn't make much
sense to call keys or seq on it (and it doesn't make *much* sense to
call vals on it if you expect the result of vals to be equinumerous
with the key/value pairs in the map). Nor does it make much sense to
call count on it.

However, since Associative extends IPersistentCollection extends
Seqable, the result is an instance of Seqable, and coll? returns true,
etc., even though, as I said, the promises those interfaces make don't
really make sense.

I could just extend ILookup, which contains only valAt, but I'd also
like to be able to implement containsKey and entryAt, which AFAICT are
only found in Associative. (If I'm wrong, please let me know---I know
that count is found in e.g. both IPersistentCollection and Counted.)
And in any case I'd like to be able to use IPersistentMap as well, for
without. There are sensible definitions of all the functions
specifically defined for IPersistentMap and Associative, but there are
*not* sensible definitions for all of what they bring along.

Is there a way to weasel out of this? Force coll? to return false,
make the runtime think these pseudo-maps aren't instances of Seqable?
Being enumerable or seqable is not a necessary property of something
that maps keys to values.

-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks,
which may be sweet, aromatic, fermented or spirit-based. ... Family
and social life also offer numerous other occasions to consume drinks
for pleasure." [Larousse, "Drink" entry]

-- 
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

Reply via email to