Sophie a écrit :

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

(:x anA) is not a special accessor function, it's just the standard use of a keyword as a lookup function for a map. Every type created by deftype behaves like a map with the field names as its keys. So if you change the field name, you ned to change the keyword used for retrieving the value.

If you want to provide an interface to your type that does not depend on your choice of field names, define your own accessor functions. For example

        (deftype A [x])
        (def get-A-value :x)

As long as you only use get-A-value in client code, you are free to change the field names in A.

Konrad


__________ Information provenant d'ESET NOD32 Antivirus, version de la base des 
signatures de virus 5016 (20100410) __________

Le message a été vérifié par ESET NOD32 Antivirus.

http://www.eset.com


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to