Package: alexandria

Macro once-only

Lambda List

once-only (specs &body forms)

Details

Evaluates forms with symbols specified in specs rebound to temporary variables, ensuring that each initform is evaluated only once.

Each of specs must either be a symbol naming the variable to be rebound, or of the form:
 (symbol initform)  
Bare symbols in specs are equivalent to
 (symbol symbol)  

Examples

 (defmacro cons1 (x) (once-only (x) `(cons ,x ,x))) => CONS1

(let ((y 0)) (cons1 (incf y))) => (1 . 1)
2012-12-9