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.

return

return

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

SYNTAX

(return  [ <expr> ] )
        <expr>          -       an expression

DESCRIPTION

The RETURN special form allows the return of an arbitrary value at arbitrary times within 'block' constructs (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 


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