Thanx for your feedback so far (Neale, BG, Steven). I would have been surprised if anyone had suggested the first forms, although I hadn't thought of the problems of using Point. outside the defining namespace so that's another strike against it.
As for the reasons for choosing defrecord over map - I totally agree Neale, and Chas's flowchart is a great reference point, but this is more a pedagogical issue (background: I'm looking at showing Clojure versions of BSL / Racket code examples that use define-struct which most closely maps (sic) to defrecord, even tho' a plain ol' map would be more idiomatic for most of the examples I am interested in documenting... although defining protocol-based versions of the functions in those examples would be an interesting diversion as well). Sean On Thu, Jul 25, 2013 at 9:41 AM, Neale Swinnerton <ne...@isismanor.com> wrote: > Chas Emerick's excellent clojure type flowchart[1] is my goto for when to > use a defrecord over deftype / plain 'ol map. > > Since the criteria to choose defrecord is basically 'do you need it to > behave like a clojure immutable map, but with enhanced protocols support' > then I'd argue that the idiomatic usage would be to treat it like a map. > > For constructor usage, i.e > > (Point. 10 10) vs (->Point 10 10) > > I'd argue for the latter. The first is painful when used from other > namespaces, because you must import the java class even if you've referred > the whole ns. Particularly confusing when you have packages with dash / > underscores in the package name. > > > [1] > http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/ > > Neale Swinnerton > {t: @sw1nn, w: sw1nn.com } > > > On 25 July 2013 17:18, Sean Corfield <seancorfi...@gmail.com> wrote: >> >> I tend to use plain ol' maps for data structures but was showing >> someone defrecord the other day and had some questions about idiomatic >> usage: >> >> Given: >> >> (defrecord Point [x y]) >> >> Which constructor form is considered more idiomatic: >> >> (Point. 10 10) or (->Point 10 10) >> >> Which accessor form is considered more idiomatic (assume pt is a Point >> record): >> >> (.x pt) or (:x pt) >> >> Are there (other) things regarding records for which idiomatic usage >> would not look just like maps? >> -- >> Sean A Corfield -- (904) 302-SEAN >> An Architect's View -- http://corfield.org/ >> World Singles, LLC. -- http://worldsingles.com/ >> >> "Perfection is the enemy of the good." >> -- Gustave Flaubert, French realist novelist (1821-1880) >> >> -- >> -- >> 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 >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> > > -- > -- > 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 > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > -- Sean A Corfield -- (904) 302-SEAN An Architect's View -- http://corfield.org/ World Singles, LLC. -- http://worldsingles.com/ "Perfection is the enemy of the good." -- Gustave Flaubert, French realist novelist (1821-1880) -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.