From 6aca99e6211a8fe97a8bb84d2bc85f9900f35315 Mon Sep 17 00:00:00 2001 From: dos-reis Date: Mon, 7 Jun 2010 18:15:49 +0000 Subject: * interp/compiler.boot (finishLambdaExpression): Bind escaped variables with LET-form instead of assignment. --- src/interp/compiler.boot | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/interp') diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot index 16222b24..6323bf51 100644 --- a/src/interp/compiler.boot +++ b/src/interp/compiler.boot @@ -329,24 +329,23 @@ finishLambdaExpression(expr is ["LAMBDA",vars,.],env) == frees is [[var,:.]] => vec := var ["LAMBDA",[:vars,var],:CDDR expandedFunction] - scode := nil + scode := nil -- list of multiple used variables, need local bindings. slist := nil -- list of single used variables, no local bindings. - locals := nil -- list of multiple used variables, need local bindings. i := -1 for v in frees repeat i := i+1 vec := [first v,:vec] rest v = 1 => slist := [[first v,"getShellEntry","$$",i],:slist] - scode := [['SETQ,first v,["getShellEntry","$$",i]],:scode] - locals := [first v,:locals] + scode := [[first v,["getShellEntry","$$",i]],:scode] body := slist => SUBLISNQ(slist,CDDR expandedFunction) CDDR expandedFunction - if locals then - if body is [["DECLARE",:.],:.] then - body := [first body,["PROG",locals,:scode, - ["RETURN",["PROGN",:rest body]]]] - else body := [["PROG",locals,:scode,["RETURN",["PROGN",:body]]]] + if scode ~= nil then + body := + body is [["DECLARE",:.],:.] => + [first body,["PROG",nreverse scode, + ["RETURN",["PROGN",:rest body]]]] + [["LET",nreverse scode,:body]] vec := ["VECTOR",:nreverse vec] ["LAMBDA",[:vars,"$$"],:body] fname := ["CLOSEDFN",expandedFunction] --Like QUOTE, but gets compiled -- cgit v1.2.3