From 183e90ee84334efe3f27ddaa21ea5bb0355dc15d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 22 Jul 2015 07:43:33 -0700 Subject: Improve bad argument diagnosis for place macros. * eval.c (op_mac_param_bind): New static function. (eval_init): Register mac-param-bind operator. * share/txr/stdlib/place.tl (define-place-macro): Use mac-param-bind inside a lambda instead of tb macro. * txr.1: Document mac-param-bind. --- txr.1 | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'txr.1') diff --git a/txr.1 b/txr.1 index 53b90055..3bf4c4ae 100644 --- a/txr.1 +++ b/txr.1 @@ -29003,9 +29003,10 @@ Rather it may be substituted by one kind of form when it is treated as a pure value, and another kind of form when it is treated as a place. -.coNP Operator @ tree-bind +.coNP Operators @ tree-bind and @ mac-param-bind .synb .mets (tree-bind < macro-style-params < expr << form *) +.mets (mac-param-bind < context-expr < macro-style-params < expr << form *) .syne .desc The @@ -29031,6 +29032,22 @@ structural mismatch between the parameters and the value of One way to avoid this exception is to use .codn tree-case . +The +.code mac-param-bind +operator is similar to +.code tree-bind +except that it takes an extra argument, +.metn context-expr. +This argument is an expression which is evaluated. It is expected to +evaluate to a compound form. If an error occurs during binding, the error +diagnostic message is based on information obtained from this form. +By contrast, the +.code tree-bind +operator's error diagnostic refers to the +.code tree-bind +form, which is cryptic if the binding is used for the implementation +of some other construct, hidden from the user of that construct. + .coNP Operator @ tree-case .synb .mets (tree-case < expr >> {( macro-style-params << form *)}*) -- cgit v1.2.3