|
|
|
|
|
by kazinator
1386 days ago
|
|
Common Lisp has this in the `setq` and `psetq` macros. E.g. exchange `x` and `y`: (psetq x y y x)
You can easily have a nesting reduced binding macro, like (var (x 1 y 1) (list x y)), with sequential binding.Untested: (defmacro var (pairs &body body)
(if (oddp (length pairs))
(error "~s: variables and init-forms must occur pairwise" 'var))
`(let* ,(loop for (var init) on pairs by #'cddr
unless (and var (symbolp var)
(not (eql var t))
(not (keywordp var)))
do
(error "~s: ~s isn't a variable name" 'var var)
collect (list var init))
,@body)))
|
|