[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Two questions about the guile module system
From: |
Joris van der Hoeven |
Subject: |
Re: Two questions about the guile module system |
Date: |
Fri, 4 Apr 2003 18:06:38 +0200 (CEST) |
> > > 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.
- Re: Two questions about the guile module system,
Joris van der Hoeven <=
- Re: Two questions about the guile module system, Joris van der Hoeven, 2003/04/05
- Re: Two questions about the guile module system, Marius Vollmer, 2003/04/05
- Re: Two questions about the guile module system, Joris van der Hoeven, 2003/04/05
- Re: Two questions about the guile module system, Marius Vollmer, 2003/04/05
- Re: Two questions about the guile module system, Paul Jarc, 2003/04/07
- Re: Two questions about the guile module system, Marius Vollmer, 2003/04/08