If you want to do something close to this, you can use (setf (symbol-value var) ...) :
> (defparameter a1 5) > (defparameter a2 6) > (setf (symbol-value (if (< a1 a2) 'a1 'a2)) nil) > a1 nil > a2 6
To get the syntax closer to the one in your question, you can define setf-expander for if :
(defsetf if (cond then else) (value) `(progn (setf (symbol-value (if ,cond ,then ,else)) ,value) ,value))
Then you can write (setf (if (< a1 a2) 'a1 'a2) nil)
However, the best way to write code is probably to do it directly, using if forms with setf in both branches:
(if (< a1 a2) (setf a1 nil) (setf a2 nil))
source share