[CLJ-1269] RFC: Anonymous functions interaction with -> and ->> threading macros Created: 28/Sep/13 Updated: 09/Dec/13 Resolved: 09/Dec/13
|Affects Version/s:||Release 1.6|
|Reporter:||Michael O. Church||Assignee:||Unassigned|
This is more of a starting point for discussion than a feature request. It'd be easy to write and submit the patch, but I want to ask if it's a good idea, since it would alter the semantics of two core macros, '
For threading macros, I'd like to special-case forms that begin with 'fn and 'fn*. It's often useful (but maybe a bad idea; that's why I'd like to start the discussion) to use the threading macros in conjunction with anonymous functions in addition to forms, like so (contrived example):
This won't compile; #(/ 1 %) expands to the form
modulo gensym, of course. The threading macro, not treating fn* and fn specially, alters that to:
which is a fn* with a non-symbol (illegal label) before its binding vector, raising an error.
Is this worth "fixing", or are the benefits to small to justify the added complexity of a special case in the ->, ->> threading macros?
|Comment by Michael O. Church [ 29/Sep/13 8:52 AM ]|
|Comment by Gary Fredericks [ 09/Dec/13 7:53 AM ]|
Just one of the special cases you'd want to consider is when fn does not mean clojure.core/fn, which is certainly realistic.
|Comment by Michael O. Church [ 09/Dec/13 10:03 AM ]|
Yes, I realize that.
Looking at the ticket again, I retract my support of this change.
Here's why: (1) that "fix" would alter the semantics of the threading macros, which would break existing code, and (2) there's a really easy way to get anonymous functions into threading macros: just surround theexpression with an extra set of parentheses.
I retract my request for this feature. It's easy enough to do this: instead of,
Saving 2 characters, like so, is not worth a breaking change IMO.
|Comment by Alex Miller [ 09/Dec/13 10:15 AM ]|
Retracted by submitter