From 41ea4bd2c8791696525aadb0a457ba36fa1d204e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 25 Jan 2017 10:29:27 -0800 Subject: New catch*, giving access to exception symbol. * eval.c (op_catch): The sys:catch operator now passes the exception symbol as the first argument of each clause. This means the catch macro must be adjusted. * share/txr/stdlib/except.tl (catch): Macro now inserts a gensym dummy first argument into each clause to take the symbol passed by the sys:catch operator. (catch*): New macro, which is identical to the previous catch macro, and thus exposes the symbol passed as the first argument. * txr.1: Documented catch*. * tests/012/struct.tl: Some gensym numbers need adjusting in one test case. --- txr.1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index c0ce427b..4abfebb1 100644 --- a/txr.1 +++ b/txr.1 @@ -33055,10 +33055,12 @@ using the .code format string and additional arguments. -.coNP Macro @ catch +.coNP Macros @ catch and @ catch* .synb .mets (catch < try-expression .mets \ \ >> {( symbol <> ( arg *) << body-form *)}*) +.mets (catch* < try-expression +.mets \ \ >> {( symbol >> ( type-arg << arg *) << body-form *)}*) .syne .desc The @@ -33113,6 +33115,18 @@ If there is only one element, takes on the value .codn nil . +The +.code catch* +macro is a variant of +.code catch +with the following difference: when +.code catch* +invokes a clause, it passes the exception symbol as the leftmost argument +.metn type-arg . +Then the exception arguments follow. In contrast, +only the exception arguments are passed to the clauses of +.codn catch . + Also see: the .code unwind-protect operator, and the functions -- cgit v1.2.3