> Renaming accessor functions has the benefit of help from the compiler,
> which will tell me if the function is not defined so I can easily
> change the client code to use new name.
I think you could just define vars that evaluate to keywords. Adopting
the convention as follows gives protection from the compiler and
affords backward compatibility:
user> (defmacro def-keywords [ks-form]
`(do ~@(for [k (eval ks-form)]
`(def ~(symbol (name k)) ~k))))
#'user/def-keywords
user> (def a-map {:good-1 11, :good-2 22})
#'user/a-map
user> (def-keywords (keys a-map))
#'user/good-2
user> (good-1 a-map)
11
user> (good-2 a-map)
22
user> (bad-1 a-map)
; ==> Unable to resolve symbol: bad-1 in this context
--
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