Sorry! Disregard my former post. In fact, get doesn't work on transients
either. Fingers too fast :/

Still, looking keys up in a map while building it, is a valid use case for
transients, because you do that with persistent collections too. Same with
sets.

At the very least, get and contains? should throw on transients, but as Mark
said: Lookup is the defining characteristic of sets and maps.

If transients support the read-only interface of their persistent variants,
why shouldn't they support generic access too?

IIRC you're supposed to convert existing reduce's and loop's by wrapping it
in (persistent! ... (transient ...)) and replacing assoc with assoc!

kind regards

Am Freitag, 16. September 2011 schrieb Herwig Hochleitner :

> Am Freitag, 16. September 2011 schrieb David Nolen :
>>
>> The other thing to consider is that - is this a contract that is desirable
>> to support? Transients are only about performance - lowering the time it
>> takes to construct a collection. Perhaps there are faster implementations
>> which cannot fulfill the contract of supporting contains?
>>
>
> Fair point!
> OTOH such an implementation would still need to support get, which is
> supposed to be fast too (the reason it's stated explicitely in the contains?
> doc is, so that people don't confuse it with some)
> In fact, one could implement contains? as
>
> (defn contains? [c x]
>   (not= ::not-found (get c x ::not-found)))
>
> right now and retain the performance guarantees. And it would work on
> transients too :)
>
> kind regards
>
>
> --
> __________________________________________________________________
> Herwig Hochleitner
>


-- 
__________________________________________________________________
Herwig Hochleitner

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