Clojure: if-let and when-let
blog.jayfields.com
blog.jayfields.com
http://lib.store.yahoo.net/lib/paulgraham/onlisp.pdf - Chapter 14 - Anaphoric Macros is on page 189.
Anaphoric macros are not idiomatic in Clojure (there is only one: proxy), implicit introduction of locals is frowned upon (and you have to fight the hygienic macro system to create them).
So if-let and when-let are not really anaphoric.
In Common Lisp, I use b-when and b-if that Kenny Tilton wrote:
(defmacro b-when (bindvar boundform &body body)
`(let ((,bindvar ,boundform))
(when ,bindvar
,@body)))
(defmacro b-if (bindvar boundform yup &optional nope)
`(let ((,bindvar ,boundform))
(if ,bindvar
,yup
,nope)))
Usage: (b-when foo (plusp 1)
(frob foo)) (b-when foo (plusp 1)
(frob foo))
These implementations also don't handle declarations correctly ;P A surprisingly tricky topic. (bwhen (foo (plusp 1))
(frob foo))
bwhen is actually the first version of the macro, heh. It does seem a bit more idiomatic with parens, but I've gotten used to the other.