;;; there is a simple, but not a good way
;;; (deftry foo [x] x)
;;; (:arglists (meta #'foo)) => ([& args__5399__auto__])
(defmacro deftry [name & fdecl]
`(defn ~name [& args#]
(try
(apply (fn ~@fdecl) args#)
(catch Error e#
(println "err caught" e#)
;;; this is
> I am impressed that you were able to write a macro without any repl...
Pretty amazed myself. Never seems to happen when it's code that I'm trying
to write for myself :-)
On Monday, September 1, 2014 12:06:45 AM UTC+10, Yehonathan Sharvit wrote:
>
> Thanks a lot Beau.
>
> Your code almost worke
Thanks a lot Beau.
Your code almost worked.
This is the working code -- you just forgot the '&' between args and body
:)
I am impressed that you were able to write a macro without any repl...
(defmacro deftry [& definition]
(if (vector? (second definition))
(let [[name args & body] de
This isn't a multimethod, it's a multiple-arity function. Anyway, you just
need to detect that someone has tried to define a multiple arity method and
change your definition accordingly. Something like below. I haven't
actually tried this code so it's almost definitely wrong but you get the
gis