Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

First of all, Clojure has struct-map, which supports keywords, much like default Common Lisp struct constructors.

Second, Clojure's defstruct is on its way out. defrecord provides similar functionality with far better performance. By default, however, it does have the positional-arguments-only flaw. My personal favorite workaround is a small macro from this post: http://groups.google.com/group/clojure/msg/5206fac13144ea99

No comment about numerical operations in Clojure: it's a sensitive topic. :)



Even the manual recommends records in lieu of struct-map.

And yes, that flaw is icky; one of the few in Hickey's otherwise excellent track-record in good taste.


The manual? What's the manual?


Here: http://clojure.org/data_structures, see the entry for StructMaps. The page on datatypes* also implies heavily that structs have been phased out in favor of records, as no reason to use structs over records is presented.

* http://clojure.org/datatypes


The defrecord constructor-by-map feature is actively being worked on for version 1.3.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: