From a74e55049fd26f6ae0fb0f37db14848161df708e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 14 Apr 2018 22:45:43 -0700 Subject: compiler: lambda: accurate determination of need-frame. * share/txr/stdlib/compiler.tl (comp-lambda): The local variable need-frame is supposed to indicate whether the lambda needs a frame for its arguments: i.e. whether it has any parameters. However the way it is calculated is poor: the fixed-pars list potentially includes the semicolon symbol : which separates the required parameters from optionals. Hence the parameter list syntax (:) will be treated as "needs frame", even though it denotes an empty parameter list, just like the syntax (). This slight flaw is now tightened up. --- share/txr/stdlib/compiler.tl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/share/txr/stdlib/compiler.tl b/share/txr/stdlib/compiler.tl index d58ed2c3..ab65f46a 100644 --- a/share/txr/stdlib/compiler.tl +++ b/share/txr/stdlib/compiler.tl @@ -675,14 +675,14 @@ (mac-param-bind form (op pars . body) form (let* ((rest-par (nthlast 0 pars)) (fixed-pars (ldiff pars rest-par)) - (need-frame (or fixed-pars rest-par)) lexsyms specials) (tree-bind (: req-pars raw-opt-pars) (split* fixed-pars (op where (op eq :))) (let* ((opt-pars (mapcar [iffi atom list] raw-opt-pars)) - (nenv (if need-frame (new env up env co me) env)) (nreq (len req-pars)) - (nfixed (+ nreq (len opt-pars)))) + (nfixed (+ nreq (len opt-pars))) + (need-frame (or (plusp nfixed) rest-par)) + (nenv (if need-frame (new env up env co me) env))) (flet ((spec-sub (sym) (cond ((special-var-p sym) -- cgit v1.2.3