This is the mail archive of the guile@cygnus.com mailing list for the guile project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
just to add to the meelee, i too like to use plain `define' and then
export symbols. under the current module system, these two are
useful:
(defmacro register-service (mod name)
`(let ((public-i (module-public-interface ,mod)))
(module-define! ,mod ,name (module-ref ,mod ,name #f))
(module-add! public-i ,name (module-variable ,mod ,name))))
(define (claim-syms syms)
(for-each (lambda (sym)
(register-service (current-module) sym))
syms))
the first is mined out of `define-public', the second a wrapper (one
could elide them). usage is something like:
(define-module (my module)
:use-module (fancy colors))
(define (fact n) (if (= 1 n) n (* n (fact (1- n)))))
(define fact-5 (fact 5))
(claim-syms fact fact-5 fancy-color-blue)
i normally just use `claim-syms' at the end of the file, but maybe
calling it earlier works too. its name is to remind me that symbols
can be exported not just from the current module being defined but
from whatever modules are pulled in via `use-modules' or the
`:use-module' clause of `define-module'. in the above example, that
capability is applied to `fancy-color-blue', from the module `(fancy
colors)'.
thi