Arc Forumnew | comments | leaders | submitlogin
2 points by rntz 5390 days ago | link | parent

I've never seen a convincing use case for currying macros; not sure why you bother with that. I find your use of 'args-key to enable reverse currying interesting - one wonders whether there are other possible uses. Personally I just use the following:

    (def curry (f . xs) (fn ys (apply f (join xs ys))))
    (def flip (f) (fn (x y . z) (apply f y x z))
As regards reversed currying and other more complex partial applications, I find the extended version of the [] syntax that I've cooked up for anarki's arc3.master branch to be quite nice - any symbol prefixed with an underscore is taken to be an argument to the function, and arguments are ordered alphabetically (with the special symbol '__ standing for the rest argument). So for example:

    arc> ([cons _2 _1] 'foo 'bar)
    (bar . foo)
    arc> ([list _ _a 0 __] 1 2 3 4)
    (1 2 0 (3 4))
In the first example, of course, [cons _2 _1] could be replaced with (flip cons).


5 points by twilightsentry 5390 days ago | link

My motivation for currying macros came from the recent "afn with" discussion. I had a w/afn macro which looked like a manually-curried function, so I figured it wouldn't hurt to add it to the curry fn:

  (mac w/afn args
    `(w/rfn self ,@args))
vs.

  (= w/afn (>_ w/rfn 'self))
Your [] syntax definitely looks useful, but I use (fn ((x y))) more than (fn (x y)).

-----

3 points by rntz 5390 days ago | link

Huh. I hadn't thought of anaphoric macros (like afn and afnwith), but it's true: they're good examples of macro currying.

-----