ORF
A macro seen in some utility/convenience layers. A simple definition (from McCLIM) is:

(define-modify-macro orf (&rest args) or)

Another possibility is to modify the place only if it's null. This definition is more involved:

(defmacro orf (place &rest forms &environment environment) (multiple-value-bind (temps vals news writer reader) (get-setf-expansion place environment) `(let* (,.(mapcar #'list temps vals)) ,(if (rest news) (flet ((mvs (form) `(multiple-value-setq ,news ,form))) `(multiple-value-bind ,news ,reader (cond (,(first news) (values ,@news)) (t (or ,.(mapcar #'mvs forms)) ,writer)))) ;; There is only one store variable. `(or ,reader (let ((,(first news) (or ,@forms))) ,writer))))))

There's also an atomic version of orf, using SBCL's get-cas-expansion.


macro example