I would like to add another idea right out of my head:

When you say you want to "hide from client code", juxtaposed to the
notion of "(def)type", a little warning manifests itself in my head,
because as far as I understand them, types are there to provide
polymorphic implementations for protocols. So protocols should be the
primary targets as an API for your clients, not types.

By being easily used as maps, types are very powerful because you can
use all the default clojure functions on them, but inside your
libraries and the codebase you own, would you like to change the
internals of the type fields". For "client code" ("client code" as
code you can't modify or for which modification is almost impossible
without annoying someone else), better stick to
interfaces/protocols/factory functions/methods. (or, as the others
have said, explicit "public API" accessor functions).

HTH,

-- 
Laurent

2010/4/11 Sophie <itsme...@hotmail.com>:
> (deftype A [x]) gives me an accessor (:x anA)
>
> Then I decide to change data representation of A without impacting
> client code, but I don't seem able to define a function
> (defn :x [anA] ...)
>
> Should I be doing something different?
>
> Thanks!
>
> --
> 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
>
> To unsubscribe, reply using "remove me" as the subject.
>

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