3 ms·
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
by gcv 16y ago
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 http://groups.google.com/group/clojure/msg/5206fac13144ea99
No comment about numerical operations in Clojure: it's a sensitive topic. :)
- mahmud 16y agoEven 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.
- amouat 16y agoThe manual? What's the manual?
- whateverer 16y agoHere: http://clojure.org/data_structures 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 http://clojure.org/datatypes
- lukev 16y agoThe defrecord constructor-by-map feature is actively being worked on for version 1.3.