I was doing some experimenting with deftypes this evening. I understand that you need to specify clojure.lang.IPersistentMap as an interface in order to make your type behave like a general-purpose map (supporting assoc, dissoc, etc.).
After playing around, I think it would be ideal that if you *don't* specify clojure.lang.IPersistentMap as an interface, you still get an implementation of assoc that works only with keys already in the type. In other words, you can't add a new field, and you can't call dissoc to remove it, but you still have the ability to say, "Give me another object just like this one, but with such-and-such value changed". In other words, I'm suggesting that if you do something like: (deftype Posn [x y]) (def p (Posn 1 2)) You should be able to do (assoc p :x 3), you should get back #:Posn{:x 1, :y 2}, however (assoc p :z 3) will not work, and (dissoc p :x) would not work. I'm mainly suggesting this because deftypes seem a bit of a pain to work with without some way to create an updated object, whereas for many purposes, the full-blown map capabilities can make your code more fragile (for example, if you really mean a Posn to contain an :x and :y, no more, no less). Thoughts? -- 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