So let me see if I can help out with this. In classic lisp, when you
define a function it would take this syntax:

(defn name (arg1 arg2)
        body)

The only problem with this approach is that sometimes it is hard to
figure out what is part of the body and what is the argument lists.
Clojure solves this by just mandating that argument lists are
vectors...this is almost purely syntactic sugar. The idea is that
using [] makes it stand out from the other forms that use ().

Now in the example you gave for subvec...we would write this in
classic lisp like this:

(subvec (vector 1 2 3 4 5) 1 3)

So we're creating a vector then running subvec on it. However, this is
a bit more verbose that what people from say Ruby and Python are used
to. It's just simpler to allow people to write

[1 2 3 4 5]

instead of

(vector 1 2 3 4 5)

So in the case of using [] as a function argument, it's considered a
vector constructor. In the case of being used in a defn, it's
considered syntactic sugar. Yes it's a tad confusing, but it makes
sense once you work it out.

I hope this helps.

Timothy


-- 
“One of the main causes of the fall of the Roman Empire was
that–lacking zero–they had no way to indicate successful termination
of their C programs.”
(Robert Firth)

-- 
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

Reply via email to