![[LISPWORKS]](/image.pl?url=http%3a%2f%2fwww.lispworks.com%2fdocumentation%2fHyperSpec%2fBody%2f..%2fGraphics%2fLWSmall.gif&f=jpg&w=240)
![[Common Lisp HyperSpec (TM)]](/image.pl?url=http%3a%2f%2fwww.lispworks.com%2fdocumentation%2fHyperSpec%2fBody%2f..%2fGraphics%2fCLHS_Sm.gif&f=jpg&w=240)
Syntax:
prog1first-formform* =>result-1
prog2first-form second-formform* =>result-2
Arguments and Values:
first-form---aform; evaluated as described below.
second-form---aform; evaluated as described below.
forms---animplicit progn; evaluated as described below.
result-1---theprimary value resulting from theevaluation offirst-form.
result-2---theprimary value resulting from theevaluation ofsecond-form.
Description:
prog1evaluatesfirst-form and thenforms,yielding as its onlyvalue theprimary valueyielded byfirst-form.
prog2evaluatesfirst-form, thensecond-form, and thenforms,yielding as its onlyvalue theprimary valueyielded byfirst-form.
Examples:
(setq temp 1) => 1 (prog1 temp (print temp) (incf temp) (print temp))>> 1>> 2=> 1 (prog1 temp (setq temp nil)) => 2 temp => NIL (prog1 (values 1 2 3) 4) => 1 (setq temp (list 'a 'b 'c)) (prog1 (car temp) (setf (car temp) 'alpha)) => A temp => (ALPHA B C) (flet ((swap-symbol-values (x y) (setf (symbol-value x) (prog1 (symbol-value y) (setf (symbol-value y) (symbol-value x)))))) (let ((*foo* 1) (*bar* 2)) (declare (special *foo* *bar*)) (swap-symbol-values '*foo* '*bar*) (values *foo* *bar*)))=> 2, 1 (setq temp 1) => 1 (prog2 (incf temp) (incf temp) (incf temp)) => 3 temp => 4 (prog2 1 (values 2 3 4) 5) => 2
Side Effects: None.
Affected By: None.
Exceptional Situations: None.
See Also:
Notes:
prog1 andprog2 are typically used toevaluate one or moreforms with side effects and return avalue that must be computed before some or all of the side effects happen.
(prog1 form*) == (values (multiple-value-prog1 form*)) (prog2 form1 form*) == (let () form1 (prog1 form*))