On Friday, April 20, 2012 4:01:54 PM UTC+9:30, David Jagoe wrote:
>
>
> On 20 April 2012 07:08, Matthew Phillips <mattp...@gmail.com> wrote:
>
>> I've always liked the way assoc and dissoc return the original map 
>> instance when there's no change to be made. But this is not apparently 
>> true of records. e.g.:
>
>
> Out of curiosity, why is this useful to you?
>
> I would imagine that the fact that it works like that for maps at the 
> moment is an implementation detail that you shouldn't rely upon.
>
> dissoc[iate]. Returns a new map of the same (hashed/sorted) type,
> that does not contain a mapping for key(s).
>

It's mainly that, when mentally reasoning about the performance of assoc 
and dissoc, I've been quite happy to say "this dissoc here will hardly ever 
actually need to *do* anything, thus have very little overhead GC-wise". 
This didn't turn out to be true of records, which was surprising.

I haven't been impacted performance-wise, but it does seem like a missed 
optimisation opportunity: I'd be interested to hear if it's harder to do 
than I think in the record case.

You're right that relying on identical? in code logic is a bad idea.

Matthew.

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