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

return


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

Syntax

(return [expr])
expr - an expression
returns - never returns

Description

The 'return' special form allows the return of an arbitrary value at arbitrary times within 'block' constructs like do , do* , dolist , dotimes , loop , prog and prog*. The 'expr' will be returned by the outer 'block' construct. A NIL will be returned by the outer 'block' construct if there is no 'expr' specified.

If 'return' is used without being within a valid 'block' construct, an error is generated:

error: no target for RETURN

Examples

(prog (i)                              ; PROG form
  (print i) (RETURN "foo") (print j))  ; prints NIL  returns "foo"

(dotimes (i 10)
  (if (eql i 5) (RETURN 20)
                (princ i)))            ; prints 01234  returns 20

(prog1 (print "hi") (RETURN "foo"))    ; prints "hi"
                                       ; error: no target for RETURN

(return 9)                             ; error: no target for RETURN

See the return special form in the XLISP 2.0 manual.

  Back to Top


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