From 705aafca215d6bf7b289f443fdebc4681776cf28 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Tue, 21 Mar 2023 19:42:14 -0700 Subject: Allow t symbol in macro parameter lists. * eval.c (expand_params_rec, bind_macro_params): Handle t specially everywhere a parameter can occur. Expansion allows the syntax through without extending the environment with a t variable; binding walks over the structure without binding a variable. * stdlib/compiler.tl (expand-bind-mac-params): Likewise, handle occurrences of t, suppressing the generation of and assignment to variables, while ensuring that initializing expressions are evaluated. * tests/011/tree-bind.tl: New file. * txr.1: Documented. --- tests/011/tree-bind.tl | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/011/tree-bind.tl (limited to 'tests') diff --git a/tests/011/tree-bind.tl b/tests/011/tree-bind.tl new file mode 100644 index 00000000..83fcaa33 --- /dev/null +++ b/tests/011/tree-bind.tl @@ -0,0 +1,20 @@ +(load "../common") + +(mtest + (tree-bind b '(1 2) b) (1 2) + (tree-bind (t b) '(1 2) b) 2 + (tree-bind (t . b) '(1 2) b) (2) + (tree-bind (b t) '(1 2) b) 1 + (tree-bind (b . t) '(1 2) b) 1 + (tree-bind t '(1 2) 3) 3 + (tree-bind (t : b) '(1 2) b) 2 + (tree-bind (b : t) '(1) b) 1 + (tree-bind (b : (t 2)) '(1) b) 1 + (tree-bind (b : (a 2 t)) '(1) a) 2 + (let ((i 0)) (tree-bind (b : (t (inc i) t)) '(1) (cons i b))) (1 . 1) + (let ((i 0)) (tree-bind (b : (t (inc i) t)) '(1 2) (cons i b))) (0 . 1)) + +(compile-only + (eval-only + (compile-file (base-name *load-path*) "temp.tlo") + (remove-path "temp.tlo"))) -- cgit v1.2.3