mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Make `(rnrs base)' independent of other rnrs modules.
* module/rnrs/base.scm (define-proxy): New macro. (raise, condition, make-error, make-assertion-violation, make-who-condition, make-message-condition, make-irritants-condition): Use it.
This commit is contained in:
parent
0e8a11c49a
commit
630b6588b7
1 changed files with 21 additions and 12 deletions
|
@ -123,24 +123,33 @@
|
|||
(define (vector-map proc . vecs)
|
||||
(list->vector (apply map (cons proc (map vector->list vecs)))))
|
||||
|
||||
(define-syntax raise
|
||||
;; Resolve the real `raise' lazily to avoid a circular dependency
|
||||
;; between `(rnrs base)' and `(rnrs exceptions)'.
|
||||
(syntax-rules ()
|
||||
((_ c)
|
||||
((@ (rnrs exceptions) raise) c))))
|
||||
(define-syntax define-proxy
|
||||
(syntax-rules (@)
|
||||
;; Define BINDING to point to (@ MODULE ORIGINAL). This hack is to
|
||||
;; make sure MODULE is loaded lazily, at run-time, when BINDING is
|
||||
;; encountered, rather than being loaded while compiling and
|
||||
;; loading (rnrs base).
|
||||
;; This avoids circular dependencies among modules and makes
|
||||
;; (rnrs base) more lightweight.
|
||||
((_ binding (@ module original))
|
||||
(define-syntax binding
|
||||
(identifier-syntax
|
||||
(module-ref (resolve-interface 'module) 'original))))))
|
||||
|
||||
(define condition
|
||||
(define-proxy raise
|
||||
(@ (rnrs exceptions) raise))
|
||||
|
||||
(define-proxy condition
|
||||
(@ (rnrs conditions) condition))
|
||||
(define make-error
|
||||
(define-proxy make-error
|
||||
(@ (rnrs conditions) make-error))
|
||||
(define make-assertion-violation
|
||||
(define-proxy make-assertion-violation
|
||||
(@ (rnrs conditions) make-assertion-violation))
|
||||
(define make-who-condition
|
||||
(define-proxy make-who-condition
|
||||
(@ (rnrs conditions) make-who-condition))
|
||||
(define make-message-condition
|
||||
(define-proxy make-message-condition
|
||||
(@ (rnrs conditions) make-message-condition))
|
||||
(define make-irritants-condition
|
||||
(define-proxy make-irritants-condition
|
||||
(@ (rnrs conditions) make-irritants-condition))
|
||||
|
||||
(define (error who message . irritants)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue