diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2025-04-19 10:54:44 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2025-04-19 10:54:44 -0700 |
commit | 787b60b4ed56e7805fd0bb5c9b3a450cc850ac9c (patch) | |
tree | 25d7defef6db18631062c9def891c920815bf388 | |
parent | 2f8679c346a88c07b81ea8e9854c71dae2ade167 (diff) | |
download | txr-787b60b4ed56e7805fd0bb5c9b3a450cc850ac9c.tar.gz txr-787b60b4ed56e7805fd0bb5c9b3a450cc850ac9c.tar.bz2 txr-787b60b4ed56e7805fd0bb5c9b3a450cc850ac9c.zip |
op: reduce and mitigate multiple expansion.
* stdlib/op.tl (sys:op-expand): Bind *expand-hook* to nil in
several places so that the unavoidable multiple expansions
we perform do not re-invoke hooks. Finally, when we
interpolate the calculated lambda-interior into the output
templates, we mark it noexpand since the material already
underwent several expansions.
-rw-r--r-- | stdlib/op.tl | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/stdlib/op.tl b/stdlib/op.tl index bd5b7a2f..26061a6f 100644 --- a/stdlib/op.tl +++ b/stdlib/op.tl @@ -125,7 +125,8 @@ ;; Try to expand args as-is, catching errors. (let ((syn (op-ignerr (sys:op-alpha-rename e syntax-0 - nil)))) + nil))) + (*expand-hook* nil)) (if syn ;; Args expanded. (if (or (slot ctx 'gens) (slot ctx 'nested)) @@ -156,6 +157,7 @@ ;; There were no metas. Let's return the ;; form augmented with do-gen. syn))))) + (*expand-hook* nil) (syntax-2 (sys:op-alpha-rename e syntax-1 t)) (metas (slot ctx 'gens)) (rec (slot ctx 'rec)) @@ -189,13 +191,13 @@ (cond (recvar ^(sys:lbind ((,rec (lambda (,*(cdr metas) . ,rest-sym) (let ((,rec (fun ,rec))) - ,lambda-interior)))) + ,(noexpand lambda-interior))))) (fun ,rec))) (rec ^(sys:lbind ((,rec (lambda (,*(cdr metas) . ,rest-sym) - ,lambda-interior))) + ,(noexpand lambda-interior)))) (fun ,rec))) (t ^(lambda (,*(cdr metas) . ,rest-sym) - ,lambda-interior)))))) + ,(noexpand lambda-interior))))))) (defmacro op (:form f :env e . args) (sys:op-expand f e args)) |