Are the square brackets around arguments in Clojure's defn
, defmacro
and binding
(am I forgetting some?) really creating a vector or is it just a matter of syntax, making the arguments stand out from the rest?
I'm reading Clojure in Action which states:
Clojure uses vectors to denote function arguments or binding forms.
which made me ask this question here.
Yes, it is really a vector. We can see that by building a function manually and then evaluating it:
(eval (list (list 'fn (vector 'x) (list '* 'x 2)) 100))
;=> 200
Hope that helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With