On Fri, Jul 17, 2009 at 12:17 PM, Laurent PETIT<laurent.pe...@gmail.com> wrote: > > 2009/7/17 Chouser <chou...@gmail.com> >> >> On Fri, Jul 17, 2009 at 11:21 AM, Mark >> Addleman<mark_addle...@bigfoot.com> wrote: >> > >> > On Jul 17, 2:35 am, Nicolas Oury <nicolas.o...@gmail.com> wrote: >> >> Hello, >> >> >> >> Can this construct handle higher-order functions? >> > >> > Nope :) >> > >> > Chouser brought up this point in IRC. It's not even clear what the >> > syntax would look like. >> >> I suppose you could provide named-arg-aware high order >> functions with their own syntax. >> >> (named-map subtract :from (range 0 30 3) :take (range 10)) >> >> But you'd need everything -- filter, reduce, etc... >> >> There is something that can be done to make a normal call >> look more ... normal. That is, instead of: >> >> (named-call subtract :from 10 :take 2) >> >> you'd prefer: >> >> (subtract :from 10 :take 2) >> >> Well, that's just a matter of writing a defn-named-args >> macro: >> >> (defn-named-args subtract [from take] (- from take)) >> >> Which would expand to something like: >> >> (do >> (defn subtract-func [from take] (- from take)) >> (defmacro subtract [& args] >> `(named-call subtract-func ~...@args))) >> >> This actually came up in IRC too. :-) Note it builds >> directly on the named-call macro you've already got. Also >> note that it enforces the inability to use this 'subtract' >> in high order functions because it's now a macro. > > Hi, though interesting, I sincerely think all this becomes a little bit too > complicated ... or maybe not general enough (starting to have to treat > "callable with named args" functions as second class citizens is a bad smell > and, maybe, not a good start in life for them ?)
Well, I'm not really advocating this use of this everywhere... But clever use of :inline could get your named-arg functions back to full citizenship, I think. But you'd still have to write named-* versions of all your high order functions. This wouldn't be a tweak to Clojure as an experimental related new language. :-) Don't forget to patch the reader so you can do: #(- %:from %:take) --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---