diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2018-03-25 19:22:16 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2018-03-25 19:22:16 -0700 |
commit | 30d0d0fb1fa657f1b4bad642dc6ea81aee9600ba (patch) | |
tree | 43b4d5850639dcc096a9db07e94055dfa847db5c /tests | |
parent | 0f2ab1fc2c9dcdc181f02b7a5b50b0cdb92b01aa (diff) | |
download | txr-30d0d0fb1fa657f1b4bad642dc6ea81aee9600ba.tar.gz txr-30d0d0fb1fa657f1b4bad642dc6ea81aee9600ba.tar.bz2 txr-30d0d0fb1fa657f1b4bad642dc6ea81aee9600ba.zip |
eval: remove hack of macro deffers evaled on expansion.
* eval.c (do_expand): When a defmacro or defsymacro form is
traversed, do not evaluate it, except in backward
compatibility mode. Unfortunately, this breaks some code.
* tests/011/macros-1.txr: A defmacro form has to be wrapped in
macro-time.
* tests/011/macros-2.txr: Likewise.
* tests/011/mandel.txr: Likewise.
* tests/012/man-or-boy.tl (defun-cbn): This macro generates a
progn which which expects that a defmacro form will come into
effect for the subsequent lambda in the same form. We must
wrap it in macro-time to make this happen now.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/011/macros-1.txr | 11 | ||||
-rw-r--r-- | tests/011/macros-2.txr | 19 | ||||
-rw-r--r-- | tests/011/mandel.txr | 15 | ||||
-rw-r--r-- | tests/012/man-or-boy.tl | 2 |
4 files changed, 25 insertions, 22 deletions
diff --git a/tests/011/macros-1.txr b/tests/011/macros-1.txr index 946cbf2e..81199c12 100644 --- a/tests/011/macros-1.txr +++ b/tests/011/macros-1.txr @@ -1,10 +1,11 @@ @(do (progn - (defmacro rem-num (:env menv some-form) - (let ((expanded (macroexpand some-form menv))) - (if (numberp (car expanded)) - (cdr expanded) - some-form))) + (macro-time + (defmacro rem-num (:env menv some-form) + (let ((expanded (macroexpand some-form menv))) + (if (numberp (car expanded)) + (cdr expanded) + some-form)))) (prinl (macrolet ((foo () '(1 list 42)) diff --git a/tests/011/macros-2.txr b/tests/011/macros-2.txr index debc6eca..a6693c6b 100644 --- a/tests/011/macros-2.txr +++ b/tests/011/macros-2.txr @@ -1,15 +1,16 @@ @(do (set *gensym-counter* 0) - (defmacro whilst ((condition : result) . body) - (let ((cblk (gensym "cnt-blk-")) - (bblk (gensym "brk-blk-"))) - ^(macrolet ((break (value) ^(return-from ,',bblk ,value))) - (symacrolet ((break (return-from ,bblk)) - (continue (return-from ,cblk))) - (block ,bblk - (for () (,condition ,result) () - (block ,cblk ,*body))))))) + (macro-time + (defmacro whilst ((condition : result) . body) + (let ((cblk (gensym "cnt-blk-")) + (bblk (gensym "brk-blk-"))) + ^(macrolet ((break (value) ^(return-from ,',bblk ,value))) + (symacrolet ((break (return-from ,bblk)) + (continue (return-from ,cblk))) + (block ,bblk + (for () (,condition ,result) () + (block ,cblk ,*body)))))))) (let ((i 0)) (whilst ((< i 100)) diff --git a/tests/011/mandel.txr b/tests/011/mandel.txr index 15195f33..8a701526 100644 --- a/tests/011/mandel.txr +++ b/tests/011/mandel.txr @@ -13,11 +13,12 @@ (defvar y-offset (+ y-centre (* 0.5 pixel-size (+ j-max 1)))) ;; complex number library - (defmacro cplx (x y) ^(cons ,x ,y)) - (defmacro re (c) ^(car ,c)) - (defmacro im (c) ^(cdr ,c)) + (macro-time + (defmacro cplx (x y) ^(cons ,x ,y)) + (defmacro re (c) ^(car ,c)) + (defmacro im (c) ^(cdr ,c)) - (defsymacro c0 (macro-time (cplx 0 0))) + (defsymacro c0 (cplx 0 0))) (macro-time (defun with-cplx-expand (specs body) @@ -28,10 +29,10 @@ ((a b . rest) ^(progn ,a ,b ,*rest)) ((a) a) (x (error "with-cplx: invalid body ~s" body)))) - (x (error "with-cplx: bad args ~s" x))))) + (x (error "with-cplx: bad args ~s" x)))) - (defmacro with-cplx (specs . body) - (with-cplx-expand specs body)) + (defmacro with-cplx (specs . body) + (with-cplx-expand specs body))) (defun c+ (x y) (with-cplx ((a b x) (c d y)) diff --git a/tests/012/man-or-boy.tl b/tests/012/man-or-boy.tl index 9c29e455..596d6eb0 100644 --- a/tests/012/man-or-boy.tl +++ b/tests/012/man-or-boy.tl @@ -44,7 +44,7 @@ (with-gensyms (hidden-fun) ^(progn (defun ,hidden-fun ()) - (defmacro ,name (. args) ^(cbn ,',hidden-fun ,*args)) + (macro-time (defmacro ,name (. args) ^(cbn ,',hidden-fun ,*args))) (set (symbol-function ',hidden-fun) ,(make-cbn-fun 'lambda args ^(block ,name (let ((,name)) ,*body ,name))))))) |