> I sort of remember Rich Hickey say this, but I am not sure :). I was a bit mistaken. In this video ( http://blip.tv/clojure/clojure-data-structures-part-2-714064 ) , around 42nd minute, he says that assoc is "the normal way" and is "more convenient" because you can assoc multiple keys and values without having to create a map out of them:
(assoc m :a 1 :b 2) ; vs. (conj m {:a 1 :b 2}) On Thursday, August 30, 2012 1:31:41 AM UTC+2, dmirylenka wrote: > > I sort of remember Rich Hickey say this, but I am not sure :). > > As far as I see it, it is generally better to use more specific functions, > as they make the assumptions about the types of the arguments more > explicit. Sometimes they are also more efficient (but probably not in this > case). > > So, for working with maps assoc is more preferable, as it is specific to > maps (at least for non-integer keys). > > Polymorphic functions are nice when the concrete argument type is not > important (e.g. list vs. vector). > But in practice very few code is not going care whether it's working with > map or a sequence - so conj is kind of overly polymorphic. > This extra polymorphism can be confusing, for instance, if one tries to > figure out the type of the following expression: > (conj something [1 2]). > > contains? is maybe another example of generic function that has created > confusion. > > That's my understanding ) . > > On Thursday, August 30, 2012 12:05:48 AM UTC+2, Meikel Brandmeyer > (kotarak) wrote: >> >> Hi, >> >> Am 29.08.2012 um 23:38 schrieb dmirylenka: >> >> > Although, code working with maps shouldn't use conj anyway. >> >> Why? >> >> Kind regards >> Meikel >> >> -- 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