|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Parameter list macros work in inside macro parameter lists,
like they do in function parameter lists. However, they
ony work at the top level. Macro parameter lists are nested;
they may contain nested parameter lists that match
corresponding shapes in the argument list.
This patch extends parameter list macros to work in
nested macro parameter lists.
* eval.c (expand_opt_params_rec, expand_params_rec):
These two functions must be extended to take a body
argument, and to return not just an expanded parameter
list but a parameter list accompanied by a body.
We do that by making them return a cons cell, whose
car is the expanded parameter list and the cdr is
the possibly transformed body. Additionally, these
functions now call expand_param_macro on nested
macro parameter lists.
(expand_params): This function becomes slightly simpler
as a result of the above changes. Because expand_params_rec
already returns a cons cell holding a parameter list and
body, we just return that as-is.
* tests/011/keyparams.tl: Added some tests of this, vie the
standard :key parameter list macro. A macro is tested
which has a nested (:key ...) parameter list in a required
parameter position as well as in an optional position.
* txr.1: Documented.
|
|
Issues reported by user vapnik spaknik. The evaluation of init
forms is incorrect. Init forms like '(x) evaluate to
'(x) rather than (x), Also, init forms are evaluated even when
the argument is present, so the entire current approach is
wrong.
* stdlib/keyparams.tl (extract-keys, extract-keys-p,
build-key-list-expr): Functions removed.
(stuff-key-params): New function.
(:key): Rework using simplified approach, with just the
stuff-key-params helper. All variables from the keyword
parameter list are bound with let. Generated code searches
the keyword parameters for values and assigns the variables as
needed, evaluating default init forms in the not-found cases.
* tests/011/keyparams.tl: New file.
|