XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

loop


Type:   -   special form (fsubr)
Source:   -   xlcont.c

Syntax

(loop body ... )
body - a series of expressions
returns - never returns [must use non-local exit]

Description

The 'loop' special form specifies a 'repeat-forever' construct. The expressions in'body' will be evaluated. When the last expression is evaluated in 'body', 'loop' will then repeat the 'body'. When a return is evaluated within a 'loop', the specified value will be returned. 'loop' itself does not generate a return value. Other exit mechanisms include go , throw , return-from and errors.

Examples

(setq i 65)                      ; initial value

(loop                            ; LOOP
  (princ (int-char i))           ;   print the character
  (if (= i 90) (return "done"))  ;   test for limit
  (setq i (1+ i)))               ;   increment and repeat
                                 ; prints ABCDEFGHIJKLMNOPQRSTUVWXYZ
                                 ; returns "done"

Note: If you create a 'loop' with no exit mechanism, you will probably have to abort your XLISP session.

See the loop special form in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next