On Fri, Apr 16, 2010 at 2:15 AM, Per Vognsen <per.vogn...@gmail.com> wrote:
> What may confuse is that map destructuring swaps the positions of keys
> and values as compared to map literals:
>
> user> (let [{x :body} {:body 42}]
>           x)
> 42
>
> It does conform to the pattern that the bound variable precedes the
> value to bind in forms like let. A benefit of this ordering is that
> destructuring patterns like {:keys [a b c]} are unambiguous.


Hi Per,

Could you explain the rationale for this swapping? Intuitively it
seems to me that (let [{ :body x } { :body 42 }] x) should bind x
to 42 -- it seems intuitive because it is binding :body to :body
and 42 to x.

I realize that this doesn't work. I want to understand why. Why
is (let [{ x :body } { :body 42 }] x) the correct way?

Asim

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