The most important difference to me is the vector syntax evaluates to
a vector, while the list syntax evaluates to function calls. In other
words, [:img {:src "foo.jpg"}] needs no other definitions to stand for
an img element. It can be created in any context, passed around, and
eventually evaluated by a function or macro to turn it into HTML.
On the other hand (:img {:src "foo.jpg"}) in a normal evaluation
context means "look up the :img key in the {:src "foo.jpg"} hash".
This is a valid interpretation, a correct Clojure expression, but it
returns nil in this case. Probably not what you meant. So every time
you want to create an img element with this syntax you have to quote
it or put it in a macro. Quoting it like '(:img {:src "foo.jpg"})
means you can't have any computation going on inside the expression to
generate content: '(:img {:src (jpg-url "foo")}) won't call my jpg-url
function. Using a macro like (html (:img {:src "foo.jpg"}) is wordy
and requires the macro to pick through the tree and figure out what
should be evaluated as a function and what should be left as a
literal.
I guess another option would be to define functions for every tag you
might want: (img {:src "foo.jpg"}) could produce what you want if
there was an img function. But this requires pre-generating all the
tag functions you'd want to use. ...and what would be the benefit
when we have the nice vector syntax built right in?
I guess my preference is clear. :-)
--Chouser
I'm curious if you're amenable to splitting up Compojure into smaller
pieces. It seems to me there's nothing inherently connecting the
routing features with the templating piece. There may be other
sensible divisions as well. My thinking is that by having smaller
pieces, people could come up with customized or innovative pieces in
place of some of Compojure without confronting an all-or-nothing type
decision.
What do you think?
--Chouser
I was a bit suspicious of the code-generation tools in Rails, but they
seemed to work well enough. ...until it came time to upgrade. Having
recently gone through a Rails upgrade on a web app, I am now firmly
against this approach. Mixing libraries and generated code into the
same directory tree as the application source just seems like a
guaranteed mess in the long run.
Perhaps having a fixed directory tree, and having tools to generate
it, isn't that bad -- a nice way to get started. Even generating
minimal stubs that the developer is then expected to fill out and/or
replace would be okay. But some of the Rails generators go quite a
bit further than that and have caused me pain.
--Chouser
On Jul 21, 2008, at 16:50, Moxley Stratton <moxley....@gmail.com>
wrote: