回指宏

一个回指宏是引入了捕获用户提供的形式的结果的变量(通常 IT)的宏。一个常见的例子是 Anaphoric If,它类似于常规的 IF,但也定义了变量 IT 来引用测试形式的结果。

(defmacro aif (test-form then-form &optional else-form)
  `(let ((it ,test-form))
     (if it ,then-form ,else-form)))

(defun test (property plist)
  (aif (getf plist property)
       (format t "The value of ~s is ~a.~%" property it)
       (format t "~s wasn't in ~s!~%" property plist)))

(test :a '(:a 10 :b 20 :c 30))
; The value of :A is 10.
(test :d '(:a 10 :b 20 :c 30))
; :D wasn't in (:A 10 :B 20 :C 30)!