One way to think of it is that both assoc and assoc! create and return new maps that are different than the originals they were given as input.
assoc never modifies the original map. assoc! might, or it might not. It depends on implementation details. A correct Clojure program will never rely on whether the original map is modified in place or not. It should always use the return value of assoc!, and assume that the map given to assoc! now has a non-specified value. I agree that the documentation could be clearer on this point. I was going to point you at clojuredocs.org, but I see that the current example there is even more misleading, making it appear that you *should* "bash it in place". I will probably fix that soon, but if someone beats me to it, all the better. Andy On Fri, Jan 27, 2012 at 1:24 PM, Bill Robertson <billrobertso...@gmail.com>wrote: > Yes, I see that now. When I read "When applied to a transient map, > adds mapping of key(s) to val(s)" in the doc string, I understood that > to mean that it modified the existing map, and the (insufficient) > poking around that I did in the repl supported that. (actually did it > past 8 now - saw it fail in same way). > > I guess under the hood its a essentially the same sort of persistent > data structure but with chunking (buffering) before it grows. > > If I wanted to submit alternate wording for the doc string, how would > I do that? i.e. where is the process for contributing outlined? > > e.g. "When applied to a transient map, adds mapping of key(s) to > val(s) in the resulting map." > > Thanks > -Bill > > On Jan 27, 4:13 pm, David Nolen <dnolen.li...@gmail.com> wrote: > > On Fri, Jan 27, 2012 at 3:08 PM, Bill Robertson > > <billrobertso...@gmail.com>wrote: > > > > > I have read (doc transient), (doc assoc!) and (doc persistent!), and I > > > don't see what I'm missing, which is why I came here for help. > > > > The documentation herehttp://clojure.org/transientssays: > > > > "Don't bash in place" > > > > Note that all the examples are done in a functional style - they actually > > use the value produced by each operation. > > > > David > > -- > 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 > -- 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