《通链参考手册》


Special Operator BLOCK

●语法设定:

block name form* => result*

●参数和值:

name---a symbol.

form---a form.

results---the values of the forms if a normal return occurs, or else, if an explicit return occurs, the values that were transferred.

●详情:

block establishes a block named name and then evaluates forms as an implicit progn.

The special operators block and return-from work together to provide a structured, lexical, non-local exit facility. At any point lexically contained within forms, return-from can be used with the given name to return control and values from the block form, except when an intervening block with the same name has been established, in which case the outer block is shadowed by the inner one.

The block named name has lexical scope and dynamic extent.

Once established, a block may only be exited once, whether by normal return or explicit return.

●例子:

 (block empty) =>  NIL
 (block whocares (values 1 2) (values 3 4)) =>  3, 4
 (let ((x 1)) 
   (block stop (setq x 2) (return-from stop) (setq x 3))
   x) =>  2
 (block early (return-from early (values 1 2)) (values 3 4)) =>  1, 2
 (block outer (block inner (return-from outer 1)) 2) =>  1
 (block twin (block twin (return-from twin 1)) 2) =>  2
 ;; Contrast behavior of this example with corresponding example of CATCH.
 (block b
   (flet ((b1 () (return-from b 1)))
     (block b (b1) (print 'unreachable))
     2)) =>  1

●受制于: 无。

●例外情况: 无。

●更多信息:

return, return-from, Section 3.1 (Evaluation)

●说明:


◇首页 § ◎章节目录 § □内容索引 § ○符号索引 § △术语表 § ※设计草案