You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Clojure
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)