syntax of ^:arglists ?

85 views
Skip to first unread message

Georgi Danov

unread,
Dec 21, 2015, 6:13:09 AM12/21/15
to Clojure
Hi,
 Is there some formal syntax used by ^:arglists? I want to express key-value pairs that are spliced, e.g. (some-fn :k1 value :k2 value)

Thanks,
Georgi

Herwig Hochleitner

unread,
Dec 21, 2015, 9:48:38 AM12/21/15
to clo...@googlegroups.com
I'd say, same as you would destructure them inline: [& {:keys [k1 k2]}]

Georgi Danov

unread,
Dec 21, 2015, 10:02:19 AM12/21/15
to clo...@googlegroups.com

I'd like the keys to be optional and destructuring does not support that.


On Mon, Dec 21, 2015, 3:48 PM Herwig Hochleitner <hhochl...@gmail.com> wrote:
I'd say, same as you would destructure them inline: [& {:keys [k1 k2]}]

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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 a topic in the Google Groups "Clojure" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojure/scSJ3cJg1Tw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Herwig Hochleitner

unread,
Dec 21, 2015, 10:16:25 AM12/21/15
to clo...@googlegroups.com
It does. When not passed, a key is nil, or you can provide an or binding: [& {:keys [k1 k2] :or {k1 :default1 k2 :default2}]

Herwig Hochleitner

unread,
Dec 21, 2015, 10:28:06 AM12/21/15
to clo...@googlegroups.com
err​ [& {:keys [k1 k2] :or {k1 :default1 k2 :default2}}]
Reply all
Reply to author
Forward
0 new messages