Guile Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reexport-from-module
Jost Boekemeier writes:
> Could you please explain the semantics of re-exporting and renaming
> of symbols?
Sure. Exporting a symbol makes its variable binding available in a
module's public interface, where another module can do `use-modules' or
`:use-module' to get to them. For example, the sequence:
(define-module (A))
(define-public pi 3.1415)
(define-module (C) :use-module (A))
(define-module (D) :use-module (C))
makes `pi' available for use by module C, but not module D. In order
for D to see `pi', C would need to re-export `pi', ie, add `pi' to its
public interface. (Currently, you can do this using `export', or
`define-public'.)
Renaming is simply defining a new symbol to bind to the variable of
another one. (Currently, you can do this using `define'.)
Suppose D wants `pi' defined as 3.14, but still wants access to A's
`pi', which it considers `exact-pi'. Then, the sequence:
(define-module (A))
(define-public pi 3.1415)
(define-module (C) :use-module (A))
(define-public exact-pi pi)
(define-module (D) :use-module (C))
(define pi 3.14)
would be a case of both re-export as well as renaming, and D would be
able to use `pi' as well as `exact-pi'. Hmmm, one doesn't need weird
syntactic cruft like `reexport-from-module' at all. (I rescind my
desire to see it added to guile, having learned something by doing this
explanation -- thanks!)
Feeling goofy, :-D
thi
Guile Home |
Main Index |
Thread Index