Here is a somewhat simpler definition :-) :

user=> (def $ clojure.core/partial)
#'user/$
user=> (def add5 ($ + 5))
#'user/add5
user=> (add5 3)
8
user=>

But maybe you want the delayed evaluation of the already included
arguments, but it is not clear to me from your e-mail (and your
example that uses a literal integer), and it's also not clear to me
what uses cases may require this macro. Could you elaborate a little
more on the subject ?

Please also note the gensym facility of clojure (get rid  of the
gensym, and autocreate a gensym by suffixing a # to a symbol inside a
syntax quote expression) :

(defmacro $ [f & args]
   `(fn [& args2#]
      (eval (cons (quote ~f) (concat (quote ~args) args2#)))))

See:
user=> (macroexpand `(args2# args2#))
(args2__44__auto__ args2__44__auto__)
user=>

Regards,

-- 
Laurent

2009/5/28 kinghajj <kingh...@gmail.com>:
>
> (defmacro $ [f & args]
>  (let [args2 (gensym)]
>    `(fn [& ~args2]
>       (eval (cons (quote ~f) (concat (quote ~args) ~args2))))))
>
> Example:
> (def add5 ($ + 5))
>
> (add5 3)
>
> Beware! For this macro evaluates the later parameters before the
> partially-applied ones, so side-effectful parameters may occur in an
> unexpected order.
> >
>

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