Friday, February 20, 2009

progn - A Special Form in Lisp

progn is a special form in lisp that causes each of its arguments to be evaluated in sequence and then returns the value of the last one.The preceding expressions are evaluated only for the side effects they perform .The values produced by them are discarded.

Syntax of PROGN:

progn form* => result*

Arguments and Values:

forms --> an implicit progn
results --> the values of the forms.

Description:

Progn evaluates forms in lisp, in the order in which they are given. The values of each form but the last are discarded. If progn appears as a top level form within that progn are considered by the compiler to be top level forms

Examples:

(progn) ==> NIL
(progn 1 2 3) ==> 3
(progn (values 2 3 4)) ==> 2, 3, 4
(setq b 1 ) ==> 1
(if b
(progn (setq b nil) 'here)
(progn (setq b t) 'there))==> HERE
a ==> NIL

No comments: