Verified Commit 7f78b9b7 authored by Vladimir Sedach's avatar Vladimir Sedach
Browse files

MAYBE-ONCE-ONLY now handles all kinds of macros

parent fe0fad36
......@@ -386,15 +386,11 @@ except that if the given VARS are variables or constants, no intermediate variab
((,vars-bound ())
,@(loop for var in vars collect
(if (or
(constantp ,var)
(symbolp ,var)
(not (lookup-macro-def ,var *symbol-macro-env*))
(not (gethash ,var *symbol-macro-toplevel*))))
(let ((var¹ (ps-gensym ',var)))
(push (list var¹ ,var) ,vars-bound)
`(let ,(reverse ,vars-bound)
(let ((form (ps-macroexpand ,var)))
(if (atom form)
(let ((var¹ (ps-gensym ',var)))
(push (list var¹ form) ,vars-bound)
`(let* ,(reverse ,vars-bound)
......@@ -4209,3 +4209,13 @@ x = 2 + sideEffect() + x + 5;")
var y2 = fun2();
return x1 + x1 + y2 + y2;
(test-ps-js maybe-once-only-macroexpansion
((A (x y)
(ps:maybe-once-only (x y)
`(+ ,x ,x ,y ,y)))
(fun1 () 'G)
(fun2 () 6))
(A (fun1) (fun2)))
"G + G + 6 + 6;")
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment