Re: Destructuring syntax

2012-01-08 Thread Jeb Beich
"Joy of Clojure" adds a second reason for this: "The second reason is because it allows us to conjure up other destructuring features by using forms that would otherwise make no sense. Because the item on the left of each pair will be a new local name, it must be a symbol or possibly a nested dest

Re: Destructuring syntax

2012-01-04 Thread Matthew Boston
I'm with Alex. I think of it as though it's a let binding, cause that's basically what's happening; the is bound to the scoped name. On Jan 4, 11:29 am, Alex Miller wrote: > I had the same thought when I first started learning Clojure - I think > the idea is that there is some nice mental resonan

Re: Destructuring syntax

2012-01-04 Thread Alex Miller
I had the same thought when I first started learning Clojure - I think the idea is that there is some nice mental resonance when destructuring matches up to your mental model of the data structure (it's literal form). In sequential destructuring, that holds but in maps it doesn't so things look "b

Re: Destructuring syntax

2012-01-04 Thread Ben Smith-Mannschott
On Wed, Jan 4, 2012 at 07:36, Johnny Weng Luu wrote: > One thing that seems weird is the way Clojure destructures a map > > I have this map: {:last-name "Vinge" :first-name "Vernor"} which is passed > to this function: (defn greet-author-2 [{fname :first-name}] ... ) > > Wouldn't it be better doin

Re: Destructuring syntax

2012-01-04 Thread Jay Fields
That does feel a bit more natural, but how would you handle :keys, :as, and :or? On Wed, Jan 4, 2012 at 1:36 AM, Johnny Weng Luu wrote: > One thing that seems weird is the way Clojure destructures a map > > I have this map: {:last-name "Vinge" :first-name "Vernor"} which is passed > to this funct

Destructuring syntax

2012-01-04 Thread Johnny Weng Luu
One thing that seems weird is the way Clojure destructures a map I have this map: {:last-name "Vinge" :first-name "Vernor"} which is passed to this function: (defn greet-author-2 [{fname :first-name}] ... ) Wouldn't it be better doing: (defn greet-author-2 [{:first-name fname}] ... ) You first