unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Weird module behaviour
@ 2014-09-25 14:04 Panicz Maciej Godek
  2014-09-25 14:25 ` Taylan Ulrich Bayirli/Kammer
  2014-09-25 16:31 ` Barry Schwartz
  0 siblings, 2 replies; 5+ messages in thread
From: Panicz Maciej Godek @ 2014-09-25 14:04 UTC (permalink / raw)
  To: guile-user@gnu.org

Hi all,
I'm trying to use Aleix Conchillo's guile-redis module for my project,
and it revealed a surprising use-case.
Namely, guile-redis consists of several modules that are put together
in one meta-module, which looks more or less like this:

(define-module (redis)
  #:use-module (redis main)
  #:use-module (redis commands connection)
  #:use-module (redis commands hashes)
  #:use-module (redis commands keys)
  ...)

(define-syntax re-export-modules
  (syntax-rules ()
    ((_ (mod ...) ...)
     (begin
       (module-use! (module-public-interface (current-module))
         (resolve-interface '(mod ...)))
        ...))))

(re-export-modules
  (redis main)
  (redis commands connection)
  (redis commands hashes)
  (redis commands keys)
  ...)

So basically the meta-module adds the interfaces of its child modules.
This isn't particularly surprising, because another way of creating a
meta-module would be to enumerat all bindings from its child modules,
which is a lot of work that would create an opportunity for
desynchronization.

However, it turns out that the modules export some names that would
interfere with another names used in my project.
Therefore, I decided to use the dedicated feature for avoiding such
conflicts -- namely, renaming.

If I (use-modules (redis)), everything works perfectly fine.
However, if I try to use #:select, e.g.

(use-modules ((redis) #:select (redis-connect))),

I get an error:

"no binding `redis-connect` in module (redis)".

Furthermore, when I try to use the #:renamer feature, like

(use-modules ((redis) #:renamer (symbol-prefix-proc 'redis:)))

then I get neither redis-connect nor redis:redis-connect exported.

I am almost certain that this weird behaviour stems from the way the
meta-module is built (although I don't know the module system
implementation well enough to point to the exact reason).

However, the questions are:

- if "resolve-interface" and "module-use!" are documented in the
manual, shouldn't they inter-operate with #:select and #:rename
features of use-modules?

- if the above are to be considered dirty hacks, then what would be
the proper way of creating meta-modules (other than listing all the
exported bindings explicitly)?

- or am I getting something wrong?

Best regards,
M.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-09-25 17:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-25 14:04 Weird module behaviour Panicz Maciej Godek
2014-09-25 14:25 ` Taylan Ulrich Bayirli/Kammer
2014-09-25 14:57   ` Panicz Maciej Godek
2014-09-25 17:57     ` Taylan Ulrich Bayirli/Kammer
2014-09-25 16:31 ` Barry Schwartz

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