1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-18 01:30:27 +02:00

deprecate @bind

* module/ice-9/boot-9.scm:
* module/ice-9/deprecated.scm (@bind): Deprecate @bind, which was a
  thread-unsafe dynamic scoping mechanism, used in the old elisp
  support. Fluids are more correct, and are probably faster, given the
  VM support for with-fluids.

* test-suite/tests/dynamic-scope.test: Remove.
* test-suite/tests/fluids.test: Move relevant tests from
  dynamic-scope.test here, recast in terms of with-fluids.
This commit is contained in:
Andy Wingo 2010-04-19 14:00:23 +02:00
parent b9e67767ae
commit 0abc210944
4 changed files with 93 additions and 121 deletions

View file

@ -470,38 +470,6 @@ If there is no handler at all, Guile prints an error and then exits."
(include-from-path "ice-9/quasisyntax")
;;; @bind is used by the old elisp code as a dynamic scoping mechanism.
;;; Please let the Guile developers know if you are using this macro.
;;;
(define-syntax @bind
(lambda (x)
(define (bound-member id ids)
(cond ((null? ids) #f)
((bound-identifier=? id (car ids)) #t)
((bound-member (car ids) (cdr ids)))))
(syntax-case x ()
((_ () b0 b1 ...)
#'(let () b0 b1 ...))
((_ ((id val) ...) b0 b1 ...)
(and-map identifier? #'(id ...))
(if (let lp ((ids #'(id ...)))
(cond ((null? ids) #f)
((bound-member (car ids) (cdr ids)) #t)
(else (lp (cdr ids)))))
(syntax-violation '@bind "duplicate bound identifier" x)
(with-syntax (((old-v ...) (generate-temporaries #'(id ...)))
((v ...) (generate-temporaries #'(id ...))))
#'(let ((old-v id) ...
(v val) ...)
(dynamic-wind
(lambda ()
(set! id v) ...)
(lambda () b0 b1 ...)
(lambda ()
(set! id old-v) ...)))))))))
;;; {Defmacros}

View file

@ -36,7 +36,9 @@
$sinh
$cosh
$tanh
closure?))
closure?
%nil
@bind))
;;;; Deprecated definitions.
@ -260,3 +262,37 @@
(procedure? x))
(define %nil #nil)
;;; @bind is used by the old elisp code as a dynamic scoping mechanism.
;;; Please let the Guile developers know if you are using this macro.
;;;
(define-syntax @bind
(lambda (x)
(define (bound-member id ids)
(cond ((null? ids) #f)
((bound-identifier=? id (car ids)) #t)
((bound-member (car ids) (cdr ids)))))
(issue-deprecation-warning
"`@bind' is deprecated. Use `with-fluids' instead.")
(syntax-case x ()
((_ () b0 b1 ...)
#'(let () b0 b1 ...))
((_ ((id val) ...) b0 b1 ...)
(and-map identifier? #'(id ...))
(if (let lp ((ids #'(id ...)))
(cond ((null? ids) #f)
((bound-member (car ids) (cdr ids)) #t)
(else (lp (cdr ids)))))
(syntax-violation '@bind "duplicate bound identifier" x)
(with-syntax (((old-v ...) (generate-temporaries #'(id ...)))
((v ...) (generate-temporaries #'(id ...))))
#'(let ((old-v id) ...
(v val) ...)
(dynamic-wind
(lambda ()
(set! id v) ...)
(lambda () b0 b1 ...)
(lambda ()
(set! id old-v) ...)))))))))