diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-10-31 07:17:20 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-10-31 07:17:20 -0700 |
commit | e313ceee48d860d3ee9591298c9ac1630096610b (patch) | |
tree | 0dc09b716d4e84be264824417c44f95c2daf45b7 /txr.1 | |
parent | 484dd64d138a1ae977af05193036d3fe46220b2c (diff) | |
download | txr-e313ceee48d860d3ee9591298c9ac1630096610b.tar.gz txr-e313ceee48d860d3ee9591298c9ac1630096610b.tar.bz2 txr-e313ceee48d860d3ee9591298c9ac1630096610b.zip |
New macros tb and tc.
* eval.c (me_tb, me_tc): New static functions.
(eval_init): Registered tb and tc macros.
* txr.1: Documented tb and tc.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 72 |
1 files changed, 72 insertions, 0 deletions
@@ -25306,6 +25306,78 @@ is important: even more so than the order of cases in a or .codn caseql . +.coNP Macro @ tb +.synb +.mets (tb < macro-style-params << form *) +.syne +.desc +The +.code tb +macro is similar to the +.code lambda +operator but its argument binding is based on a macro-style parameter list. +The name is an abbreviation of +.codn tree-bind . + +A +.code tb +form evaluates to a function which takes a variable number of +arguments. + +When that function is called, those arguments are taken as a list object which +is matched against +.meta macro-style-params +as if by +.metn tree-bind . +If the match is successful, then the parameters are bound to the +corresponding elements from the argument structure and each successive +.meta form +is evaluated an environment in which those bindings are visible. +The value of the last +.meta form +is the return value of the function. If there are no forms, +the function's return value is +.codn nil . + +The following equivalence holds, where +.code args +should be understood to be a globally unique symbol: + +.cblk + (tb pattern body ...) <--> (lambda (. args) + (tree-bind pattern args body ...)) +.cble + +.coNP Macro @ tc +.synb +.mets (tc >> {( macro-style-params << form *)}*) +.syne +.desc +The +.code tc +macro produces an anonymous function whose behavior is closely +based on the +.code tree-case +operator. Its name is an abbreviation of +.codn tree-case . + +The anonymous function takes a variable number of arguments. +Its argument list is taken to be the value macro is tested +against the multiple pattern clauses of an implicit +.codn tree-bind . +The return value of the function is that of the implied +.codn tree-bind . + +The following equivalence holds, where +.code args +should be understood to be a globally unique symbol: + +.cblk + (tc clause1 clause2 ...) <--> (lambda (. args) + (tree-bind args + clause1 clause2 ...)) +.cble + .SS* Debugging Functions .coNP Functions source-loc and source-loc-str .synb |