* Re: Two questions about the guile module system
[not found] <878yuvd14m.fsf@zagadka.ping.de>
@ 2003-04-04 16:06 ` Joris van der Hoeven
0 siblings, 0 replies; only message in thread
From: Joris van der Hoeven @ 2003-04-04 16:06 UTC (permalink / raw)
Cc: guile-devel
> > > What about:
> > >
> > > module.scm
> > >
> > > (define-module (module)
> > > :use-module (library))
> > >
> > > ...
> > > (foo)
> > > ...
> > >
> > > This way, 'module' says explicitely that it is using bindings from
> > > 'library'.
> >
> > That is precisely what I do not want to do. The point is that
> > I have not one library module, but dozens of them. I do not want
> > to respecify all of them over and over again.
>
> Then what about making a new macro that does this speciying for you?
>
> For example:
>
> (define-macro (define-my-module name . rest)
> `(define-module ,name
> :use-module (library)
> ,@rest))
>
> You then only need to make sure that 'define-my-module' is available
> in the current module when you load a file that uses it.
This is not very satisfactory either, in my opinion.
But I did find a way to hack exporting all symbols
from the public interface of a module.
With this, both my original questions can be answered.
Here is the code:
(define-macro (export-from . which-list)
(define (module-exports which)
(let* ((m (resolve-module which #f))
(m-public (module-ref m '%module-public-interface #f))
(l '()))
(module-for-each (lambda (symb . tail) (set! l (cons symb l))) m-public)
l))
(let ((l (apply append (map module-exports which-list))))
`(export ,@l)))
If you want to include that piece of code into Guile,
then please go ahead. One might want to replace 'export'
by 're-export' in recent versions of Guile.
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2003-04-04 16:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <878yuvd14m.fsf@zagadka.ping.de>
2003-04-04 16:06 ` Two questions about the guile module system Joris van der Hoeven
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).