On Nov 13, 1:01 pm, Constantine Vetoshev <gepar...@gmail.com> wrote:
> On Nov 12, 7:10 am, Rich Hickey <richhic...@gmail.com> wrote:
>
> > [1]http://www.assembla.com/wiki/show/clojure/Datatypes
>
> Could you please elaborate on why you chose to make IPersistentMap an
> optional interface for deftype'd types, rather than making it
> automatic?
>

Because we want to be able to use deftype to implement
PersistentHashMap and datatypes like it.

> I'm asking because I found the automatic defstruct-map equivalence
> convenient in writing the Cupboard database library (http://github.com/
> gcv/cupboard). It guaranteed that any reading Clojure code could read
> back any map or any struct written by any other Clojure program
> (unless the map contains closures, of course), without any other
> knowledge of the writing program. It allows for data-centric designs
> when thinking about storing objects to a database, i.e., the data can
> be used without the type definitions which originally produced it.
>
> I can, of course, require that any deftype'd types saved in Cupboard
> databases implement IPersistentMap, but I'm curious about the
> reasoning for not making maps part of the default nature of deftype.
> Making IPersistentMap the default could also make deftype a nearly
> drop-in replacement for defstruct.
>

Making it default, and having some way to opt out, is another
possibility. This is still an open question, as well as how to make
these default implementations more extensible.

Rich

-- 
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

Reply via email to