(defmacro try-or
"Evaluates exprs one at a time, from left to right. If a form returns a
value, this value is returned. If a form throws an exception, the next
form is evaluated.
If the last form throws an exception, the exception isn't caught."
([] nil)
([form] form)
([form & forms]
`(try
~form
(catch Exception e#
(try-or ~@forms)))))
Thursday, January 8, 2009
try-or, or-try, try-else or else-try?
This post has moved,
go to its new location
I can't decide which name is best for this macro:
Subscribe to:
Post Comments (Atom)
7 comments:
try-cond
No, never mind. try-or
why not 'try-one ?
It most closely matches the existing function some. So maybe try-some?
grayswx: some is a function (plus it takes a predicate), or is a macro. I think try-or is better.
try-harder!
Post a Comment