The documentation on records seems to indicate that they be used in
place of structs, but is there any advantage to using a record if no
protocols are assigned to it?
For example, I've defined a TcpServer record as part of a library I'm
developing:
(defrecord TcpServer
[port
host
backlog
handler
socket
connections])
(defn tcp-server [& {:as options}]
{:pre [(:port options) (:handler options)]}
(TcpServer.
(:port options)
(:host options "127.0.0.1")
(:backlog options 50)
(:handler options)
(atom nil)
(atom #{})))
Is this idiomatic Clojure, or should I just use a map instead:
(defn tcp-server [& {:as options}]
(merge
{:host "127.0.0.1"
:backlog 50
:socket (atom nil)
:connections (atom #{})
options))
- James
--
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