From: David Vazquez Date: Sat, 19 Jan 2013 20:09:16 +0000 (+0000) Subject: Use let* instead of nested lets X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=0e25a1125a032c1a90f4b5cd375c874461aa5f62;p=jscl.git Use let* instead of nested lets --- diff --git a/ecmalisp.lisp b/ecmalisp.lisp index 519d04e..e145a74 100644 --- a/ecmalisp.lisp +++ b/ecmalisp.lisp @@ -1335,24 +1335,24 @@ "}" *newline*)) (define-compilation let (bindings &rest body) - (let ((bindings (mapcar #'ensure-list bindings))) - (let ((variables (mapcar #'first bindings))) - (let ((cvalues (mapcar #'ls-compile (mapcar #'second bindings))) - (*environment* (extend-local-env (remove-if #'special-variable-p variables))) - (dynamic-bindings)) - (concat "(function(" - (join (mapcar (lambda (x) - (if (special-variable-p x) - (let ((v (gvarname x))) - (push (cons x v) dynamic-bindings) - v) - (translate-variable x))) - variables) - ",") - "){" *newline* - (let ((body (ls-compile-block body t))) - (indent (let-binding-wrapper dynamic-bindings body))) - "})(" (join cvalues ",") ")"))))) + (let* ((bindings (mapcar #'ensure-list bindings)) + (variables (mapcar #'first bindings)) + (cvalues (mapcar #'ls-compile (mapcar #'second bindings))) + (*environment* (extend-local-env (remove-if #'special-variable-p variables))) + (dynamic-bindings)) + (concat "(function(" + (join (mapcar (lambda (x) + (if (special-variable-p x) + (let ((v (gvarname x))) + (push (cons x v) dynamic-bindings) + v) + (translate-variable x))) + variables) + ",") + "){" *newline* + (let ((body (ls-compile-block body t))) + (indent (let-binding-wrapper dynamic-bindings body))) + "})(" (join cvalues ",") ")"))) ;;; Return the code to initialize BINDING, and push it extending the @@ -1362,10 +1362,10 @@ (value (second binding))) (if (special-variable-p var) (concat (ls-compile `(setq ,var ,value)) ";" *newline*) - (let ((v (gvarname var))) - (let ((b (make-binding var 'variable v))) - (prog1 (concat "var " v " = " (ls-compile value) ";" *newline*) - (push-to-lexenv b *environment* 'variable))))))) + (let* ((v (gvarname var)) + (b (make-binding var 'variable v))) + (prog1 (concat "var " v " = " (ls-compile value) ";" *newline*) + (push-to-lexenv b *environment* 'variable)))))) ;;; Wrap BODY to restore the symbol values of SYMBOLS after body. It ;;; DOES NOT generate code to initialize the value of the symbols,