[CLJ-211] Support arbitrary functional destructuring via -> and ->> Created: 17/Nov/09 Updated: 10/Dec/10 |
|
| Status: | In Progress |
| Project: | Clojure |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | Approved Backlog |
| Type: | Enhancement | Priority: | Minor |
| Reporter: | Assembla Importer | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Approval: | Incomplete |
| Description |
|
Support arbitrary functional destructuring, that is the use of The discussion began here: The attached patch implements the spec described here: That is, the following examples would now work: user=> (let [(-> str a) 1] a) user=> (let [[a (-> str b) c] [1 2]] (list a b c)) user=> (let [(->> (map int) [a b]) "ab"] (list a b)) |
| Comments |
| Comment by Assembla Importer [ 28/Sep/10 6:57 AM ] |
|
Converted from http://www.assembla.com/spaces/clojure/tickets/211 |
| Comment by Assembla Importer [ 28/Sep/10 6:57 AM ] |
|
chouser@n01se.net said: [file:aHWQ_W06Kr3O89eJe5afGb]: [PATCH] Support -> and ->> in destructuring forms. |
| Comment by Assembla Importer [ 28/Sep/10 6:57 AM ] |
|
cgrand said: I think the current patch suffers from the problem described here http://groups.google.com/group/clojure-dev/msg/80ba7fad2ff04708 too. |
| Comment by Assembla Importer [ 28/Sep/10 6:57 AM ] |
|
richhickey said: so, don't use syntax-quote, just use clojure.core/-> |
| Comment by Assembla Importer [ 28/Sep/10 6:57 AM ] |
|
chouser@n01se.net said: Only -> and ->> are actually legal here anyway – if you've locally bound foo to -> there's not really any good reason to think (fn [(foo inc a)] a) should work. And if you've redefined -> or ->> to mean something else in your ns, do we need to catch that at compile time, or is it okay to emit the rearranged code and see what happens? In short, would '#{ |
| Comment by Assembla Importer [ 28/Sep/10 6:57 AM ] |
|
cgrand said: Only -> and ->> are legal here but what if they are aliased or shadowed? Instead of testing the symboil per se I would check, if:
(when-not (&env (first b)) (#{#'clojure.core/-> #'clojure.core/->>} (resolve (first b))))
but it requires to change destructure's sig to pass the env around |
| Comment by Stuart Halloway [ 03/Dec/10 1:03 PM ] |
|
Rich: Are you assigned to this by accident? If so, please deassign yourself. |