Movatterモバイル変換


[0]ホーム

URL:


[LISPWORKS][Common Lisp HyperSpec (TM)][Previous][Up][Next]


Special OperatorRETURN-FROM

Syntax:

return-fromname [result] =>|

Arguments and Values:

name---ablock tag; not evaluated.

result---aform; evaluated. The default isnil.

Description:

Returns control andmultiple values[2] from a lexically enclosingblock.

Ablockform namedname must lexically enclose the occurrence ofreturn-from; anyvaluesyielded by theevaluation ofresult are immediately returned from the innermost such lexically enclosingblock.

The transfer of control initiated byreturn-from is performed as described inSection 5.2 (Transfer of Control to an Exit Point).

Examples:

 (block alpha (return-from alpha) 1) =>  NIL (block alpha (return-from alpha 1) 2) =>  1 (block alpha (return-from alpha (values 1 2)) 3) =>  1, 2 (let ((a 0))    (dotimes (i 10) (incf a) (when (oddp i) (return)))    a) =>  2 (defun temp (x)    (if x (return-from temp 'dummy))    44) =>  TEMP (temp nil) =>  44 (temp t) =>  DUMMY (block out   (flet ((exit (n) (return-from out n)))     (block out (exit 1)))   2) =>  1 (block nil      (unwind-protect (return-from nil 1)     (return-from nil 2)))=>  2 (dolist (flag '(nil t))   (block nil     (let ((x 5))       (declare (special x))       (unwind-protect (return-from nil)         (print x))))   (print 'here))>>  5>>  HERE>>  5>>  HERE=>  NIL (dolist (flag '(nil t))   (block nil     (let ((x 5))       (declare (special x))       (unwind-protect           (if flag (return-from nil))         (print x))))   (print 'here))>>  5>>  HERE>>  5>>  HERE=>  NIL

The following has undefined consequences because theblockform exits normally before thereturn-fromform is attempted.

 (funcall (block nil #'(lambda () (return-from nil)))) is an error.

Affected By: None.

Exceptional Situations: None.

See Also:

block,return,Section 3.1 (Evaluation)

Notes: None.


The followingX3J13 cleanup issue,not part of the specification, applies to this section:


[Starting Points][Contents][Index][Symbols][Glossary][Issues]
Copyright 1996-2005, LispWorks Ltd. All rights reserved.


[8]ページ先頭

©2009-2025 Movatter.jp