Re: surprising behaviour from dissoc on records

2016-02-19 Thread Beau Fabry
Interesting. I think it makes sense in that `dissoc` is a function for removing a kv pair from a map, not a function for setting v to nil given a k. I could definitely see tripping up on this though. On Friday, February 19, 2016 at 8:07:16 AM UTC-8, Alex Miller wrote: > > You can find some of th

Re: surprising behaviour from dissoc on records

2016-02-19 Thread Alex Miller
You can find some of the background for this at http://clojure.org/reference/datatypes. Records are intended to capture "application domain information" - where the fields are known. Dissoc'ing means you are removing not just a value, but the whole "field", and the implication here is that you

surprising behaviour from dissoc on records

2016-02-19 Thread Stig Brautaset
Dissoc behaviour on records really surprised me: user> (defrecord Foo [bar]) ;; => user.Foo user> (def foo (->Foo nil)) ;; => #'user/foo user> (dissoc foo :bar) ;; => {} user> (assoc foo :bar nil) ;; => #user.Foo{:bar nil} It lead to a bug where a component of min