I picked up a tip from a post from Meikel about specifying the
function name for multi-methods for debugging purposes. It got me
thinking, wouldn't this make sense as default behaviour? I guess it
looses some flexibility to have the name automatically defined but
gains some conciseness:

(defmacro defmethod
  "Creates and installs a new method of multimethod associated with
dispatch-value. "
  [multifn dispatch-val & fn-tail]
  `(. ~multifn addMethod ~dispatch-val
      (fn ~(symbol (str multifn "-" dispatch-val)) ~...@fn-tail)))

; just added ~(symbol (str multifn "-" dispatch-val)) after fn
; to make it named at creation so it will show in stack traces
; but now fn-tail cannot have a custom name
; (if you ever wanted one - I can't think why)

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