On Sat, 28 Aug 2010 12:23:04 -0400
John Newman <john...@gmail.com> wrote:

> A reader macro for destructuring might be nifty, like #[...].

I don't think so.

But first, we already have an "on-demand" destructuring facility: let.

> So you could do things like:
> 
> (#(map (partial reduce +) #[[[[a b c][d e f]]] %]) signal)

which would be

(#(map (partial reduce +) (let [[[[a b c][d e f]]] %] [a b c d e f])) signal)

But using let allows you to put the destructuring first, which I
think is a bit easier to read:

(#(let [[[[a b c][d e f]]] %] (map (partial reduce +) [a b c d e f])) signal)

> Not sure if that'd be the right syntax, but you get the point.

I think so. It's sort of like fn and #(, only "backwards". #( lets you
elide the argument list by creating implicit names for them, so it's
as flexible as fn and a bit shorter. #[, on the other hand, elides the
body part of the let, just giving you back the list. This isn't nearly
as flexible as let, since all you get is a list, with no chance to
plug the values into an expression where they'll do the most good.

Another issue: What does this mean:

   #[[[[a b c]]] (first signal) [[[d e f]]] (second signal)]

And finally, the names (a, b, etc.) are pointless. Why not just call
them %1, %2, %3 so that you could do:

     #[[[[%3 %2 %1][%4 %5 %6]]] signal] -> [c b a d e f]

Except then you have to worry about #[[%1 %1 %2] value], so maybe just
make them all %?

       <mike
-- 
Mike Meyer <m...@mired.org>             http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

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