mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-17 09:10:22 +02:00
@ and @@ as primitive macros
* libguile/eval.h: * libguile/eval.c (error_unbound_variable, error_defined_variable): Move these prototypes up earlier. (scm_m_at, scm_m_atat): New functions, provide the @ and @@ functionality. Moved here from defmacros because they are "special", inasmuch as syncase doesn't really understand them in interpreted code. * module/ice-9/boot-9.scm (@, @@): Don't define as defmacros, as defmacros have to actually return source now.
This commit is contained in:
parent
900761bc8d
commit
249bab1c53
3 changed files with 47 additions and 28 deletions
|
@ -2936,31 +2936,6 @@ module '(ice-9 q) '(make-q q-length))}."
|
|||
|
||||
(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))
|
||||
|
||||
|
||||
|
||||
;;; {Compiler interface}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue