Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are the square brackets in Clojure's defn, defmacro and binding really a vector?

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.

like image 777
Michiel Borkent Avatar asked Mar 29 '10 18:03

Michiel Borkent


1 Answers

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.

like image 59
fogus Avatar answered Jan 04 '23 09:01

fogus