guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: New syntax: (: MODULE-NAME VARIABLE-NAME)


From: Marius Vollmer
Subject: Re: New syntax: (: MODULE-NAME VARIABLE-NAME)
Date: Sat, 15 Nov 2003 16:19:39 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Neil Jerram <address@hidden> writes:

> OK.  One other specification query: will `:' only work if the relevant
> binding is exported?

Yes, I think that's more disciplined.  Here is the actual code:

    ;; 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))


-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405




reply via email to

[Prev in Thread] Current Thread [Next in Thread]