On Thu, Jan 05 2017, Tianxiang Xiong wrote > We can have: > > user=> {(+ 1 2) 1 (+ 2 1) 2} > IllegalArgumentException Duplicate key: 3 > clojure.lang.PersistentArrayMap.createWithCheck > (PersistentArrayMap.java:71) > > > So clearly a check is also made *after* evaluating the key forms. I'm just > not sure why we need to check *before* evaluating the key forms.
The problem is that the reader produces a *map* as the result of reading the form. Given '(+ 1 2) is equal to '(+ 1 2), the reader can't store both values (because a map has only one value per key). Instead of picking one of them arbitrarily (with the surprising behaviour of dropping a form at /read/ time) it throws an exception. Carlo -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
signature.asc
Description: PGP signature