mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-12 14:50:19 +02:00
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'.
This commit is contained in:
parent
03e00c5c9d
commit
e5a361d1f9
3 changed files with 7 additions and 75 deletions
|
@ -42,7 +42,6 @@
|
||||||
compile-let*
|
compile-let*
|
||||||
compile-lexical-let*
|
compile-lexical-let*
|
||||||
compile-flet*
|
compile-flet*
|
||||||
compile-with-always-lexical
|
|
||||||
compile-guile-ref
|
compile-guile-ref
|
||||||
compile-guile-primitive
|
compile-guile-primitive
|
||||||
compile-while
|
compile-while
|
||||||
|
@ -62,11 +61,6 @@
|
||||||
|
|
||||||
(define bindings-data (make-fluid))
|
(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))
|
(define lexical-binding (make-fluid))
|
||||||
|
|
||||||
;;; Find the source properties of some parsed expression if there are
|
;;; Find the source properties of some parsed expression if there are
|
||||||
|
@ -245,13 +239,10 @@
|
||||||
(or (eq? module 'lexical)
|
(or (eq? module 'lexical)
|
||||||
(eq? module function-slot)
|
(eq? module function-slot)
|
||||||
(and (equal? module value-slot)
|
(and (equal? module value-slot)
|
||||||
(let ((always (fluid-ref always-lexical)))
|
(or (get-lexical-binding (fluid-ref bindings-data) sym)
|
||||||
(or (eq? always 'all)
|
(and
|
||||||
(memq sym always)
|
(fluid-ref lexical-binding)
|
||||||
(get-lexical-binding (fluid-ref bindings-data) sym)
|
(not (global? (fluid-ref bindings-data) sym module)))))))
|
||||||
(and
|
|
||||||
(fluid-ref lexical-binding)
|
|
||||||
(not (global? (fluid-ref bindings-data) sym module))))))))
|
|
||||||
|
|
||||||
(define (split-let-bindings bindings module)
|
(define (split-let-bindings bindings module)
|
||||||
(let iterate ((tail bindings)
|
(let iterate ((tail bindings)
|
||||||
|
@ -604,26 +595,6 @@
|
||||||
expr))
|
expr))
|
||||||
(make-const loc 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
|
;;; Special operators
|
||||||
|
|
||||||
(defspecial progn (loc args)
|
(defspecial progn (loc args)
|
||||||
|
@ -732,14 +703,6 @@
|
||||||
((,bindings . ,body)
|
((,bindings . ,body)
|
||||||
(generate-let* loc function-slot 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
|
;;; guile-ref allows building TreeIL's module references from within
|
||||||
;;; elisp as a way to access data within the Guile universe. The module
|
;;; elisp as a way to access data within the Guile universe. The module
|
||||||
;;; and symbol referenced are static values, just like (@ module symbol)
|
;;; and symbol referenced are static values, just like (@ module symbol)
|
||||||
|
@ -924,12 +887,6 @@
|
||||||
(case key
|
(case key
|
||||||
((#:warnings) ; ignore
|
((#:warnings) ; ignore
|
||||||
#f)
|
#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
|
(else (report-error #f
|
||||||
"Invalid compiler option"
|
"Invalid compiler option"
|
||||||
key)))))))
|
key)))))))
|
||||||
|
@ -941,8 +898,7 @@
|
||||||
|
|
||||||
(define (compile-tree-il expr env opts)
|
(define (compile-tree-il expr env opts)
|
||||||
(values
|
(values
|
||||||
(with-fluids ((bindings-data (make-bindings))
|
(with-fluids ((bindings-data (make-bindings)))
|
||||||
(always-lexical '()))
|
|
||||||
(process-options! opts)
|
(process-options! opts)
|
||||||
(let ((compiled (compile-expr expr)))
|
(let ((compiled (compile-expr expr)))
|
||||||
(ensuring-globals (location expr) bindings-data compiled)))
|
(ensuring-globals (location expr) bindings-data compiled)))
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
(compile-let* . let*)
|
(compile-let* . let*)
|
||||||
(compile-lexical-let* . lexical-let*)
|
(compile-lexical-let* . lexical-let*)
|
||||||
(compile-flet* . flet*)
|
(compile-flet* . flet*)
|
||||||
(compile-with-always-lexical . with-always-lexical)
|
|
||||||
(compile-guile-ref . guile-ref)
|
(compile-guile-ref . guile-ref)
|
||||||
(compile-guile-primitive . guile-primitive)
|
(compile-guile-primitive . guile-primitive)
|
||||||
(compile-while . while)
|
(compile-while . while)
|
||||||
|
@ -58,7 +57,6 @@
|
||||||
let*
|
let*
|
||||||
lexical-let*
|
lexical-let*
|
||||||
flet*
|
flet*
|
||||||
with-always-lexical
|
|
||||||
guile-ref
|
guile-ref
|
||||||
guile-primitive
|
guile-primitive
|
||||||
while
|
while
|
||||||
|
|
|
@ -315,33 +315,11 @@
|
||||||
(= (funcall c1) 4)
|
(= (funcall c1) 4)
|
||||||
(= (funcall c2) 3)))
|
(= (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"
|
(pass-if "lexical lambda args"
|
||||||
(progn (setq a 1 b 1)
|
(progn (setq a 1 b 1)
|
||||||
(defun dyna () a)
|
(defun dyna () a)
|
||||||
(defun dynb () b)
|
(defun dynb () b)
|
||||||
(with-always-lexical (a c)
|
(lexical-let (a c)
|
||||||
((lambda (a b &optional c)
|
((lambda (a b &optional c)
|
||||||
(and (= a 3) (= (dyna) 1)
|
(and (= a 3) (= (dyna) 1)
|
||||||
(= b 2) (= (dynb) 2)
|
(= b 2) (= (dynb) 2)
|
||||||
|
@ -352,7 +330,7 @@
|
||||||
; is tail-optimized by doing a deep recursion that would otherwise overflow
|
; is tail-optimized by doing a deep recursion that would otherwise overflow
|
||||||
; the stack.
|
; the stack.
|
||||||
(pass-if "lexical lambda tail-recursion"
|
(pass-if "lexical lambda tail-recursion"
|
||||||
(with-always-lexical (i)
|
(lexical-let (i)
|
||||||
(setq to 1000000)
|
(setq to 1000000)
|
||||||
(defun iteration-1 (i)
|
(defun iteration-1 (i)
|
||||||
(if (< i to)
|
(if (< i to)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue