Simpler yet using metadata:
(ns example.ppfn)

(defn print-pf [pf]
  (if-let [ppf (::ppf (meta pf))] ppf pf))

(defmacro partial* [& args]
  `(let [m#  (pr-str '(partial* ~@args))
         pf# (with-meta (partial ~@args) {::ppf m#})]
     (defmethod print-method (class pf#) [o# w#] (print-simple 
(example.ppfn/print-pf o#) w#))
     pf#))

In use:
user=> (def p1 (partial* + 1))
#'user/p1
user=> (p1 5)
6
user=> p1
(example.ppfn/partial* + 1)
user=> (def comma-join (partial* clojure.string/join ", "))
#'user/comma-join
user=> (comma-join ['a 'b 'c])
"a, b, c"
user=> comma-join
(example.ppfn/partial* clojure.string/join ", ")

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to