So I'm catching up with the 1.3 defrecord additions (best docs here
afaik: http://dev.clojure.org/display/design/defrecord+improvements -
will http://clojure.org/datatypes be updated?)

In 1.2, records were constructed only with the positional Java
constructor:
  (defrecord Person [first last])
  (Person. "alex" "miller")

In 1.3, there are now a plethora of new construction options:
Positional:
p1)  (Person. "alex" "miller")           ;; "legacy" Java constructor
form
p2)  (#user.Person["alex" "miller"])   ;; reader form, ns required
p3)  (->Person "alex" "miller")          ;; factory function

Map:
m1)  (#user.Person{:first "alex" :last "miller"})   ;; reader form, ns
required, default print form
m2)  (map->Person {:first "alex" :last "miller"})  ;; factory function
m3)  (Person/create {:first "alex" :last "miller"})  ;; static class
factory method

So my question is what my first choice should be when constructing
records and needing positional or map forms?  Re positional forms, the
p2 reader form requires the ns so is probably more typing than I'm
likely to do.  I'm guessing that p3 is now preferred over p1 as it
hides the interop form.  So I'll take p3 as the preferred first
choice.

For maps, m1 is the default form serialization form but requires the
ns, so I doubt I would choose that first.  m3 clearly seems designed
for tool usage and does Java interop, so I'm guessing m2 is the likely
preferred first choice.

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

Reply via email to