Name

prog

Usage

special-form

Syntax

(prog (binding*) form*)

Description

prog allows tail recursion with recur. The binding defines the parameters and initial arguments of the recursion. The recur form should be in a tail position. If recur is not used, prog is similar to Common Lisp's prog.

return returns from the directly enclosing prog or lambda.

user 1 > (defun fac (n)
             (prog ((n n) (a 1))
                 (if (plus? n)
                       (recur (dec n) (* a n))
                     a)))
it: fac
user 2 > (fac 30)
it: 265252859812191058636308480000000

A function is an implicit prog.

user 1 > (defun fac (n &optional (a 1))
             (if (plus? n)
                   (recur (dec n) (* a n))
                 a))
it: fac
user 2 > (fac 30)
it: 265252859812191058636308480000000

See also

recur return self