for macro does not allow :let clause in first position

Description

I like to try and keep my level of nesting under control, and this
often involves hiding or re-structuring the let macro. The for macro
can implicitly assemble a let macro for you, but with a limitation
that the :let clause can't be first:

Is this limitation intentional? Could the error message be improved?

Here's what I wanted to write:

(the formatting is probably scrambled)

But I had to juggle it to this:

Of course there are any number of ways to write this, but I prefer the
first option, as it does less of a job of obscuring what the main
point of the function is: a call to extend-dom.

Environment

None

Attachments

1

Activity

Show:

import December 26, 2012 at 11:13 AM

Comment made by: cmotricz

I came here to report this as a bug.

I respect Rich's decision to disallow :let at the beginning of a (for), of course, but I feel that if the syntax is to be declared illegal then the compiler should report an error rather than explode with an exception.

Thus I suggest catching the error in the compiler and reporting it as a syntax error.

Rich Hickey April 13, 2012 at 3:20 PM

just put the for in a let please

Tassilo Horn March 22, 2012 at 5:21 PM

The attached patch implements that feature and also adds tests for it. The new tests and all other tests still pass.

The patch exploits the fact that

is equivalent to

and thus transforms the former binding vector to the latter.

import August 24, 2010 at 12:56 PM

Comment made by: importer

Converted from http://www.assembla.com/spaces/clojure/tickets/207

Declined

Details

Assignee

Reporter

Patch

Code and Test

Priority

Created October 25, 2009 at 3:22 PM
Updated December 26, 2012 at 11:13 AM
Resolved December 26, 2012 at 11:13 AM