On 8 September 2015 at 11:38, Thomas Heller <i...@zilence.net> wrote:
>
> If you look at these implementations
>
> (def OneOff [(s/one s/Str 'name) (s/one s/Str 'email)])
>
> (s/defrecord OneOff
>     [name :- s/Str
>      email :- s/Str])
>
> (defrecord OneOff [name email])
>
> All of them do more or less the same thing, just different. Clojure has
> really good support for records and they feel natural to me. I don't need
> to remember that :email is the second field. So I can do (:email one-off)
> instead of (get one-off 1). Remembering the positions can get tedious and
> very error prone over time. Always remember that software evolves over time.
>
> (:email one-off) still works if my data changes to (defrecord OneOff [name
> note email]), the vector version doesn't. Referring to things by name is a
> good thing.
>

I think everyone agrees that in the above example, a map or record would be
better than a vector. The discussion is more is how to represent what's
loosely analogous to a single key and value pair.

For instance, which one of these to you consider to be the best
representation of a event to set the expiry time:

   [:cache/expire #inst "2015-09-08T12:00:00Z"]

   {:type :cache/expire, :value #inst "2015-09-08T12:00:00Z"}

   #cache.Expire [#inst "2015-09-08T12:00:00Z"]

   #cache.Expire {:value #inst "2015-09-08T12:00:00Z"}

- James

-- 
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/d/optout.

Reply via email to