Next: Generalized Variables, Up: Control Structure
The cl-psetq form is just like setq, except that multiple
assignments are done in parallel rather than sequentially.
This special form (actually a macro) is used to assign to several variables simultaneously. Given only one symbol and form, it has the same effect as
setq. Given several symbol and form pairs, it evaluates all the forms in advance and then stores the corresponding variables afterwards.(setq x 2 y 3) (setq x (+ x y) y (* x y)) x ⇒ 5 y ;ywas computed afterxwas set. ⇒ 15 (setq x 2 y 3) (cl-psetq x (+ x y) y (* x y)) x ⇒ 5 y ;ywas computed beforexwas set. ⇒ 6The simplest use of
cl-psetqis(cl-psetq x y y x), which exchanges the values of two variables. (Thecl-rotatefform provides an even more convenient way to swap two variables; see Modify Macros.)
cl-psetqalways returnsnil.