Previous: do - doing, Up: Unconditional Execution [Contents][Index]
return expr
The ‘return’ construct terminates a loop and returns the value of the specified
expression as the value of the loop. This construct is similar to the Common
Lisp special form return-from
and the Common Lisp macro return
.
The Loop Facility supports the ‘return’ construct for backward compatibility with older loop implementations. The ‘return’ construct returns immediately and does not execute any ‘finally’ clause that is given.
;;; Signal an exceptional condition. (loop for item in '(1 2 3 a 4 5) when (not (numberp item)) return (cerror "enter new value" "non-numeric value: ~s" item)) ;Signals an error ;;; >>Error: non-numeric value: A
;;; The previous example is equivalent to the following one. (loop for item in '(1 2 3 a 4 5) when (not (numberp item)) do (return (cerror "enter new value" "non-numeric value: ~s" item))) ;Signals an error ;;; >>Error: non-numeric value: A