Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

prog*

prog*

type: special form (fsubr)
location: built-in
source file: xlcont.c
Common LISP compatible: yes
supported on: all machines

SYNTAX

(prog*  ( [ <binding> ... ]  )  [ <expr> ... ]  )
        <binding>       -       a variable binding which is can take one of 
                                <symbol>     or    ( <symbol> <init-expr> )
        <symbol>        -       a symbol
        <init-expr>     -       an initialization expression for <symbol>
        <expr>          -       expressions comprising the body of the loop
                                which may contain RETURNs, GOs or tags for GO  

DESCRIPTION

The PROG* special form is basically a 'block' construct (like a PASCAL BEGIN / END) that contains symbols (with optional initializations) and a block of code (expressions) to evaluate. The PROG* form evaluates its initializations in sequential order (as opposed to PROG which does it in no specified order). The first form after the PROG* is the 'binding' form. It contains a series of <symbol>'s or <binding>'s. The <binding> is a <symbol> followed by an initialization expression <init-expr>. If there is no <init-expr>, the <symbol> will be initialized to NIL. The order of execution of the bindings is sequential. If a RETURN form is evaluated, its value will be returned. Otherwise, NIL is returned. When the PROG* is finished execution, the <symbol>'s that were defined will no longer exist or retain their values.

EXAMPLES

(prog* (i j)                            ; PROG* with vars I and J
      (print i) (print j))              ; prints  NIL NIL  returns NIL
(prog* ((i 1) (j 2))                    ; PROG* with vars I and J
      (print i) (print j)               ;
      (return (+ i j)))                 ; prints  1 2      returns 3
(prog* () (print "hello"))              ; prints  "hello"  returns NIL
                                        ;
(prog ((i 1) (j (+ i 1)))               ; PROG won't work due to order
      (print (+ i j)) )                 ; error: unbound variable - I
(prog* ((i 1) (j (+ i 1)))              ; PROG* will work due to order
       (print (+ i j)) )                ; prints  3        returns NIL


Go to the first, previous, next, last section, table of contents.