diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-04-21 06:43:28 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-04-21 06:43:28 -0700 |
commit | 43e0e33ced93434fd32c050ab3ca68a1e7231932 (patch) | |
tree | a2d957af68b4a9cc755385404ccdb8024f0e7126 /share | |
parent | 2dd44160458c9d8293faddf5156b9cef08eea7c0 (diff) | |
download | txr-43e0e33ced93434fd32c050ab3ca68a1e7231932.tar.gz txr-43e0e33ced93434fd32c050ab3ca68a1e7231932.tar.bz2 txr-43e0e33ced93434fd32c050ab3ca68a1e7231932.zip |
compile/eval: new operator, mac-env-param-bind.
mac-env-param-bind is like mac-param-bind but also allows
the value for the :env parameter to be specified.
* eval.c (op_mac_env_param_bind_s): New sy mbol variable.
(op_mac_env_param_bind): New static function.
(do_expand): Handle mac_env_param_bind_s.
(eval_init): Initialize symbol variable and register macro.
* share/txr/stdlib/compiler.tl (compiler compile): Add case
for mac-env-param-bind.
(compiler comp-mac-env-param-bind): New method.
* share/txr/stdlib/doc-syms.tl: Updated with new hashes for
tree-bind and mac-param-bind, and inclusion of
mac-env-param-bind.
* tests/012/binding.tl: New file.
* txr.1: Documented.
Diffstat (limited to 'share')
-rw-r--r-- | share/txr/stdlib/compiler.tl | 12 | ||||
-rw-r--r-- | share/txr/stdlib/doc-syms.tl | 5 |
2 files changed, 15 insertions, 2 deletions
diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index 88612e60..127d68af 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -506,6 +506,7 @@ (dohash me.(compile oreg env (expand-dohash form))) (tree-bind me.(comp-tree-bind oreg env form)) (mac-param-bind me.(comp-mac-param-bind oreg env form)) + (mac-env-param-bind me.(comp-mac-env-param-bind oreg env form)) (tree-case me.(comp-tree-case oreg env form)) (sys:lisp1-value me.(comp-lisp1-value oreg env form)) (dwim me.(comp-dwim oreg env form)) @@ -1498,6 +1499,17 @@ obj-var t nil body))))) me.(compile oreg env expn))))) +(defmeth compiler comp-mac-env-param-bind (me oreg env form) + (mac-param-bind form (op context menv params obj . body) form + (with-gensyms (obj-var form-var) + (let ((expn (expand ^(let* ((,obj-var ,obj) + (,form-var ,context)) + ,(expand-bind-mac-params form-var + form-var + params menv + obj-var t nil body))))) + me.(compile oreg env expn))))) + (defmeth compiler comp-tree-case (me oreg env form) (mac-param-bind form (op obj . cases) form (let* ((ncases (len cases)) diff --git a/share/txr/stdlib/doc-syms.tl b/share/txr/stdlib/doc-syms.tl index b980e6b3..64ad54dd 100644 --- a/share/txr/stdlib/doc-syms.tl +++ b/share/txr/stdlib/doc-syms.tl @@ -931,7 +931,7 @@ ("o-rdwr" "N-034BF6C9") ("len" "N-03AD172A") ("progn" "N-03F7A8B8") - ("tree-bind" "N-00A580D9") + ("tree-bind" "N-021A9008") ("tb" "N-02AB6E53") ("rpos" "N-01F68300") ("buf-get-int" "N-03C7C985") @@ -1150,6 +1150,7 @@ ("make-random-state" "N-032BEE6C") ("dir-name" "N-02C01721") ("rfind-if" "N-0301CDB6") + ("mac-env-param-bind" "N-021A9008") ("scan" "N-03E989D0") ("vmin" "N-01812D70") ("copy-list" "N-006ED237") @@ -1712,7 +1713,7 @@ ("indent-foff" "N-00512FDD") ("env-fbindings" "N-0018DCDC") ("keep-if*" "N-01413802") - ("mac-param-bind" "N-00A580D9") + ("mac-param-bind" "N-021A9008") ("ignerr" "N-007287AC") (":match" "N-03B92C0D") ("set-max-length" "N-031FA9E5") |