mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-31 17:30:24 +02:00
(cond-expand): Define using
`procedure->memoizing-macro' to get at the lexical environment. Use `env-module' instead of `current-module' to get the right module.
This commit is contained in:
parent
e24ca5385a
commit
9f79272ab3
1 changed files with 61 additions and 59 deletions
|
@ -2741,9 +2741,10 @@
|
||||||
(append (hashq-ref %cond-expand-table mod '())
|
(append (hashq-ref %cond-expand-table mod '())
|
||||||
features)))))
|
features)))))
|
||||||
|
|
||||||
(define-macro (cond-expand clause . clauses)
|
(define cond-expand
|
||||||
|
(procedure->memoizing-macro
|
||||||
(let ((clauses (cons clause clauses))
|
(lambda (exp env)
|
||||||
|
(let ((clauses (cdr exp))
|
||||||
(syntax-error (lambda (cl)
|
(syntax-error (lambda (cl)
|
||||||
(error "invalid clause in `cond-expand'" cl))))
|
(error "invalid clause in `cond-expand'" cl))))
|
||||||
(letrec
|
(letrec
|
||||||
|
@ -2752,10 +2753,11 @@
|
||||||
(cond
|
(cond
|
||||||
((symbol? clause)
|
((symbol? clause)
|
||||||
(or (memq clause %cond-expand-features)
|
(or (memq clause %cond-expand-features)
|
||||||
(let lp ((uses (module-uses (current-module))))
|
(let lp ((uses (module-uses (env-module env))))
|
||||||
(if (pair? uses)
|
(if (pair? uses)
|
||||||
(or (memq clause
|
(or (memq clause
|
||||||
(hashq-ref %cond-expand-table (car uses) '()))
|
(hashq-ref %cond-expand-table
|
||||||
|
(car uses) '()))
|
||||||
(lp (cdr uses)))
|
(lp (cdr uses)))
|
||||||
#f))))
|
#f))))
|
||||||
((pair? clause)
|
((pair? clause)
|
||||||
|
@ -2801,7 +2803,7 @@
|
||||||
(syntax-error c))
|
(syntax-error c))
|
||||||
`(begin ,@(cdar c)))
|
`(begin ,@(cdar c)))
|
||||||
(else
|
(else
|
||||||
(lp (cdr c))))))))
|
(lp (cdr c))))))))))
|
||||||
|
|
||||||
;; This procedure gets called from the startup code with a list of
|
;; This procedure gets called from the startup code with a list of
|
||||||
;; numbers, which are the numbers of the SRFIs to be loaded on startup.
|
;; numbers, which are the numbers of the SRFIs to be loaded on startup.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue