summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-11-09 06:29:33 -0800
committerKaz Kylheku <kaz@kylheku.com>2015-11-09 06:29:33 -0800
commit138d080d30e2540459e1f53e3aa950d4c6f6785c (patch)
treeaaf2ae0533662fb44e1e91c35194180542cf5e66 /txr.1
parent84af229255b1e5a594a54907adc317b61828a989 (diff)
downloadtxr-138d080d30e2540459e1f53e3aa950d4c6f6785c.tar.gz
txr-138d080d30e2540459e1f53e3aa950d4c6f6785c.tar.bz2
txr-138d080d30e2540459e1f53e3aa950d4c6f6785c.zip
New block* op; functions return* and sys:abscond*.
* eval.c (block_star_s): New symbol variable. (op_block_star): New static function. (do_expand): Handle block* symbol. (return_star, abscond_star): New static functions. (eval_init): Initialize block_star_s variable. Register block* operator and return* and sys:abscond* functions. * txr.1: Documented new operator and functions.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.195
1 files changed, 93 insertions, 2 deletions
diff --git a/txr.1 b/txr.1
index c2f25772..05bbe0fc 100644
--- a/txr.1
+++ b/txr.1
@@ -12559,9 +12559,10 @@ allowing the
operator to be used to terminate at any point.
-.coNP Operator @ block
+.coNP Operators @ block and @ block*
.synb
.mets (block < name << body-form *)
+.mets (block* < name-form << body-form *)
.syne
.desc
The
@@ -12577,6 +12578,15 @@ and
A block named by the symbol nil is slightly special: it is
understood to be an anonymous block.
+The
+.code block*
+operator differs from
+.code block
+in that it evaluates
+.metn name-form ,
+which is expected to produce a symbol. The resulting symbol
+is used for the name of the block.
+
A named or anonymous block establishes an exit point for the
.code return-from
or
@@ -12610,6 +12620,11 @@ block
does not lexically surround
.codn foo .
+It is because blocks are dynamic that the
+.code block*
+variant exists; for lexically scoped blocks, it would make little
+sense to have support a dynamically computed name.
+
Thus blocks in \*(TL provide dynamic non-local returns, as well
as returns out of lexical nesting.
@@ -12633,7 +12648,21 @@ is not allowed in Common Lisp, but can be transliterated to:
Note that foo is quoted in CL. This underscores the dynamic nature of
the construct.
.code throw
-itself is a function and not an operator.
+itself is a function and not an operator. Also note that the CL
+example, in turn, is even more closely transcribed back into \*(TL
+simply by replacing its
+.code throw
+and
+.code catch
+with
+.code return*
+and
+.code block* :
+
+.cblk
+ (defun func () (return* 'foo 42))
+ (block* 'foo (func))
+.cble
Common Lisp blocks also do not support delimited continuations.
@@ -12685,6 +12714,37 @@ terminates block
.codn foo ,
and so the second pprint form is not evaluated.
+.coNP Function @ return*
+.synb
+.mets (return* < name <> [ value ])
+.syne
+.desc
+The
+.code return*
+function is similar to the the
+.code return-from
+operator, except that
+.code name
+is an ordinary function parameter, and so when
+.code return*
+is used, an argument expression must be specified which evaluates
+to a symbol. Thus
+.code return*
+allows the target block of a return to be dynamically computed.
+
+The following equivalence holds between the operator and function:
+
+.cblk
+ (return-from a b) <--> (return* 'a b)
+.cble
+
+Expressions used as
+.meta name
+arguments to
+.code return*
+which do not simply quote a symbol have no equivalent in
+.codn return-from .
+
.SS* Evaluation
.coNP Function @ eval
@@ -27724,6 +27784,37 @@ operators to escape out of a block in which a continuation has
been captured. Neglecting to unwind is valid due to the expectation
that control will return into a restarted copy of that context.
+.coNP Function @ sys:abscond*
+.synb
+.mets (sys:abscond* < name <> [ value ])
+.syne
+.desc
+The
+.code sys:return*
+function is similar to the the
+.code sys:abscond-from
+operator, except that
+.code name
+is an ordinary function parameter, and so when
+.code return*
+is used, an argument expression must be specified which evaluates
+to a symbol. Thus
+.code sys:abscond*
+allows the target block of a return to be dynamically computed.
+
+The following equivalence holds between the operator and function:
+
+.cblk
+ (sys:abscond-from a b) <--> (sys:abscond* 'a b)
+.cble
+
+Expressions used as
+.meta name
+arguments to
+.code abscond*
+which do not simply quote a symbol have no equivalent in
+.codn abscond-from .
+
.coNP Macros @ obtain and @ yield-from
.synb
.mets (obtain << forms *)