mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +02:00
eval-when matches situations symbolically
* module/ice-9/psyntax.scm (chi-when-list): Just match symbolically instead of lexically, so as not to tie the meaning of eval-when to the bindings of eval, load, compile, and expand.
This commit is contained in:
parent
5138551787
commit
aa5698fb53
1 changed files with 11 additions and 10 deletions
|
@ -1066,20 +1066,21 @@
|
|||
|
||||
(define chi-when-list
|
||||
(lambda (e when-list w)
|
||||
;; when-list is syntax'd version of list of situations
|
||||
;; `when-list' is syntax'd version of list of situations. We
|
||||
;; could match these keywords lexically, via free-id=?, but then
|
||||
;; we twingle the definition of eval-when to the bindings of
|
||||
;; eval, load, expand, and compile, which is totally unintended.
|
||||
;; So do a symbolic match instead.
|
||||
(let f ((when-list when-list) (situations '()))
|
||||
(if (null? when-list)
|
||||
situations
|
||||
(f (cdr when-list)
|
||||
(cons (let ((x (car when-list)))
|
||||
(cond
|
||||
((free-id=? x #'compile) 'compile)
|
||||
((free-id=? x #'load) 'load)
|
||||
((free-id=? x #'eval) 'eval)
|
||||
((free-id=? x #'expand) 'expand)
|
||||
(else (syntax-violation 'eval-when
|
||||
"invalid situation"
|
||||
e (wrap x w #f)))))
|
||||
(cons (let ((x (syntax->datum (car when-list))))
|
||||
(if (memq x '(compile load eval expand))
|
||||
x
|
||||
(syntax-violation 'eval-when
|
||||
"invalid situation"
|
||||
e (wrap (car when-list) w #f))))
|
||||
situations))))))
|
||||
|
||||
;; syntax-type returns six values: type, value, e, w, s, and mod. The
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue