diff options
author | Marius Vollmer <mvo@zagadka.de> | 2003-11-17 00:28:03 +0000 |
---|---|---|
committer | Marius Vollmer <mvo@zagadka.de> | 2003-11-17 00:28:03 +0000 |
commit | 473687d1307aaed9d63f4cad1335e7ee6a010ff3 (patch) | |
tree | c21ffd9e9b070a466b0df63ed155624007fc9475 | |
parent | b58e7420391f8ff674a8bae3474743ff0ff5ffc9 (diff) | |
download | guile-473687d1307aaed9d63f4cad1335e7ee6a010ff3.tar.gz |
(@, @@): New macros.
-rw-r--r-- | ice-9/boot-9.scm | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ice-9/boot-9.scm b/ice-9/boot-9.scm index 512b47655..3989f69e9 100644 --- a/ice-9/boot-9.scm +++ b/ice-9/boot-9.scm @@ -2893,6 +2893,31 @@ (define load load-module) +;; The following macro allows one to write, for example, +;; +;; (@ (ice-9 pretty-print) pretty-print) +;; +;; to refer directly to the pretty-print variable in module (ice-9 +;; pretty-print). It works by looking up the variable and inserting +;; it directly into the code. This is understood by the evaluator. +;; Indeed, all references to global variables are memoized into such +;; variable objects. + +(define-macro (@ mod-name var-name) + (let ((var (module-variable (resolve-interface mod-name) var-name))) + (if (not var) + (error "no such public variable" (list '@ mod-name var-name))) + var)) + +;; The '@@' macro is like '@' but it can also access bindings that +;; have not been explicitely exported. + +(define-macro (@@ mod-name var-name) + (let ((var (module-variable (resolve-module mod-name) var-name))) + (if (not var) + (error "no such variable" (list '@@ mod-name var-name))) + var)) + ;;; {Parameters} ;;; |