diff options
author | Daniel Kraft <d@domob.eu> | 2009-08-01 13:00:27 +0200 |
---|---|---|
committer | Daniel Kraft <d@domob.eu> | 2009-08-01 13:00:27 +0200 |
commit | dfbc6e9d5415def4cf61c9caa9f44af056348741 (patch) | |
tree | 545acff6dbba119ff51baaa6bf06aec544692b19 /test-suite/tests/elisp-compiler.test | |
parent | c808c926fd35aeb5a3fd7768ea50edc060d48420 (diff) | |
download | guile-dfbc6e9d5415def4cf61c9caa9f44af056348741.tar.gz |
Allow lexical binding of lambda arguments.
* module/language/elisp/compile-tree-il.scm: Rework lambda compiler to allow
opional lexical binding of (some) lambda arguments.
* test-suite/tests/elisp-compiler.test: Check this.
Diffstat (limited to 'test-suite/tests/elisp-compiler.test')
-rw-r--r-- | test-suite/tests/elisp-compiler.test | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/test-suite/tests/elisp-compiler.test b/test-suite/tests/elisp-compiler.test index 5a9f6fe13..3d3bb1d6e 100644 --- a/test-suite/tests/elisp-compiler.test +++ b/test-suite/tests/elisp-compiler.test @@ -327,6 +327,8 @@ (lexical-let ((a 2) (b 42)) (and (= a 2) (= (dyna) 1) ((lambda (a) (and (= a 3) (= b 42) (= (dyna) 3))) 3) + ((lambda () (let ((a 3)) + (and (= a 3) (= (dyna) 1))))) (= a 2) (= (dyna) 1))) (= a 1))) @@ -364,7 +366,37 @@ (defun dyna () a) (with-always-lexical (a) (let ((a 1)) - (and (= a 1) (= (dyna) 0))))))) + (and (= a 1) (= (dyna) 0)))))) + + (pass-if "lexical lambda args" + (progn (setq a 1 b 1) + (defun dyna () a) + (defun dynb () b) + (with-always-lexical (a c) + ((lambda (a b &optional c) + (and (= a 3) (= (dyna) 1) + (= b 2) (= (dynb) 2) + (= c 1))) + 3 2 1)))) + + ; Check if a lambda without dynamically bound arguments + ; is tail-optimized by doing a deep recursion that would otherwise overflow + ; the stack. + (pass-if "lexical lambda tail-recursion" + (with-always-lexical (i) + (setq to 1000000) + (defun iteration-1 (i) + (if (< i to) + (iteration-1 (1+ i)))) + (iteration-1 0) + (setq x 0) + (defun iteration-2 () + (if (< x to) + (setq x (1+ x)) + (iteration-2))) + (iteration-2) + t))) + (with-test-prefix/compile "defconst and defvar" |