summaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-04-14 22:45:43 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-04-14 22:45:43 -0700
commitce51feaa6f783cea151bdc0b542a8733cce2c245 (patch)
tree0f7c6cbede245f868e6031cc8446ab63cf5b8fe3 /share
parentb1718cf88484b311911361bbad2f22c24d026d02 (diff)
downloadtxr-ce51feaa6f783cea151bdc0b542a8733cce2c245.tar.gz
txr-ce51feaa6f783cea151bdc0b542a8733cce2c245.tar.bz2
txr-ce51feaa6f783cea151bdc0b542a8733cce2c245.zip
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.
Diffstat (limited to 'share')
-rw-r--r--share/txr/stdlib/compiler.tl6
1 files 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)