diff options
author | Ludovic Courtès <ludo@gnu.org> | 2011-02-22 00:32:13 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2011-02-22 00:32:39 +0100 |
commit | 630b6588b7b26bf96874b235ff43ee4c3974cce3 (patch) | |
tree | 53b5507ccbce5d7cb74be181d86c1edf109741c0 /module/rnrs | |
parent | 0e8a11c49a0ccc8d76807133e9abf82f8e14d1ec (diff) | |
download | guile-630b6588b7b26bf96874b235ff43ee4c3974cce3.tar.gz |
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.
Diffstat (limited to 'module/rnrs')
-rw-r--r-- | module/rnrs/base.scm | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/module/rnrs/base.scm b/module/rnrs/base.scm index 4c9c51bb0..2f5a218de 100644 --- a/module/rnrs/base.scm +++ b/module/rnrs/base.scm @@ -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 condition + (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-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) |