diff options
author | BT Templeton <bpt@hcoop.net> | 2011-07-10 17:07:42 -0400 |
---|---|---|
committer | BT Templeton <bpt@hcoop.net> | 2012-02-03 18:53:49 -0500 |
commit | e5a361d1f9c7ff150ae740abcf66a85467b1deca (patch) | |
tree | cfbcefceb757aecdd527bd82fd84385adf253472 | |
parent | 03e00c5c9ddbeda56543da94601142df40e2bcbb (diff) | |
download | guile-e5a361d1f9c7ff150ae740abcf66a85467b1deca.tar.gz |
remove `with-always-lexical' elisp special form
* module/language/elisp/compile-tree-il.scm: (always-lexical): Remove.
All uses changed.
(with-added-symbols): Remove.
(compile-with-always-lexical): Remove.
(process-options!): Remove support for the `#:always-lexical' option.
* module/language/elisp/runtime/function-slot.scm: Update import and
re-export lists.
* test-suite/tests/elisp-compiler.test: Remove or update tests using
`with-always-lexical'.
-rw-r--r-- | module/language/elisp/compile-tree-il.scm | 54 | ||||
-rw-r--r-- | module/language/elisp/runtime/function-slot.scm | 2 | ||||
-rw-r--r-- | test-suite/tests/elisp-compiler.test | 26 |
3 files changed, 7 insertions, 75 deletions
diff --git a/module/language/elisp/compile-tree-il.scm b/module/language/elisp/compile-tree-il.scm index 20d79421b..5363fec2c 100644 --- a/module/language/elisp/compile-tree-il.scm +++ b/module/language/elisp/compile-tree-il.scm @@ -42,7 +42,6 @@ compile-let* compile-lexical-let* compile-flet* - compile-with-always-lexical compile-guile-ref compile-guile-primitive compile-while @@ -62,11 +61,6 @@ (define bindings-data (make-fluid)) -;;; Store which symbols (or all/none) should always be bound lexically, -;;; even with ordinary let and as lambda arguments. - -(define always-lexical (make-fluid)) - (define lexical-binding (make-fluid)) ;;; Find the source properties of some parsed expression if there are @@ -245,13 +239,10 @@ (or (eq? module 'lexical) (eq? module function-slot) (and (equal? module value-slot) - (let ((always (fluid-ref always-lexical))) - (or (eq? always 'all) - (memq sym always) - (get-lexical-binding (fluid-ref bindings-data) sym) - (and - (fluid-ref lexical-binding) - (not (global? (fluid-ref bindings-data) sym module)))))))) + (or (get-lexical-binding (fluid-ref bindings-data) sym) + (and + (fluid-ref lexical-binding) + (not (global? (fluid-ref bindings-data) sym module))))))) (define (split-let-bindings bindings module) (let iterate ((tail bindings) @@ -604,26 +595,6 @@ expr)) (make-const loc expr))) -;;; Temporarily update a list of symbols that are handled specially -;;; (e.g., always lexical) for compiling body. We need to handle special -;;; cases for already all / set to all and the like. - -(define (with-added-symbols loc fluid syms body) - (if (null? body) - (report-error loc "symbol-list construct has empty body")) - (if (not (or (eq? syms 'all) - (and (list? syms) (and-map symbol? syms)))) - (report-error loc "invalid symbol list" syms)) - (let ((old (fluid-ref fluid)) - (make-body (lambda () (compile-expr `(progn ,@body))))) - (if (eq? old 'all) - (make-body) - (let ((new (if (eq? syms 'all) - 'all - (append syms old)))) - (with-fluids ((fluid new)) - (make-body)))))) - ;;; Special operators (defspecial progn (loc args) @@ -732,14 +703,6 @@ ((,bindings . ,body) (generate-let* loc function-slot bindings body)))) -;;; Temporarily set symbols as always lexical only for the lexical scope -;;; of a construct. - -(defspecial with-always-lexical (loc args) - (pmatch args - ((,syms . ,body) - (with-added-symbols loc always-lexical syms body)))) - ;;; guile-ref allows building TreeIL's module references from within ;;; elisp as a way to access data within the Guile universe. The module ;;; and symbol referenced are static values, just like (@ module symbol) @@ -924,12 +887,6 @@ (case key ((#:warnings) ; ignore #f) - ((#:always-lexical) - (if (valid-symbol-list-arg? value) - (fluid-set! always-lexical value) - (report-error #f - "Invalid value for #:always-lexical" - value))) (else (report-error #f "Invalid compiler option" key))))))) @@ -941,8 +898,7 @@ (define (compile-tree-il expr env opts) (values - (with-fluids ((bindings-data (make-bindings)) - (always-lexical '())) + (with-fluids ((bindings-data (make-bindings))) (process-options! opts) (let ((compiled (compile-expr expr))) (ensuring-globals (location expr) bindings-data compiled))) diff --git a/module/language/elisp/runtime/function-slot.scm b/module/language/elisp/runtime/function-slot.scm index edb4ebf63..80f5d72dd 100644 --- a/module/language/elisp/runtime/function-slot.scm +++ b/module/language/elisp/runtime/function-slot.scm @@ -33,7 +33,6 @@ (compile-let* . let*) (compile-lexical-let* . lexical-let*) (compile-flet* . flet*) - (compile-with-always-lexical . with-always-lexical) (compile-guile-ref . guile-ref) (compile-guile-primitive . guile-primitive) (compile-while . while) @@ -58,7 +57,6 @@ let* lexical-let* flet* - with-always-lexical guile-ref guile-primitive while diff --git a/test-suite/tests/elisp-compiler.test b/test-suite/tests/elisp-compiler.test index 819884fb8..2074c8d39 100644 --- a/test-suite/tests/elisp-compiler.test +++ b/test-suite/tests/elisp-compiler.test @@ -315,33 +315,11 @@ (= (funcall c1) 4) (= (funcall c2) 3))) - (pass-if "always lexical option (all)" - (progn (setq a 0) - (defun dyna () a) - (let ((a 1)) - (and (= a 1) (= (dyna) 0)))) - #:opts '(#:always-lexical all)) - (pass-if "always lexical option (list)" - (progn (setq a 0 b 0) - (defun dyna () a) - (defun dynb () b) - (let ((a 1) - (b 1)) - (and (= a 1) (= (dyna) 0) - (= b 1) (= (dynb) 1)))) - #:opts '(#:always-lexical (a))) - (pass-if "with-always-lexical" - (progn (setq a 0) - (defun dyna () a) - (with-always-lexical (a) - (let ((a 1)) - (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) + (lexical-let (a c) ((lambda (a b &optional c) (and (= a 3) (= (dyna) 1) (= b 2) (= (dynb) 2) @@ -352,7 +330,7 @@ ; is tail-optimized by doing a deep recursion that would otherwise overflow ; the stack. (pass-if "lexical lambda tail-recursion" - (with-always-lexical (i) + (lexical-let (i) (setq to 1000000) (defun iteration-1 (i) (if (< i to) |