[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Weird module behaviour

From: Panicz Maciej Godek
Subject: Weird module behaviour
Date: Thu, 25 Sep 2014 16:04:06 +0200

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 ...) ...)
       (module-use! (module-public-interface (current-module))
         (resolve-interface '(mod ...)))

  (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

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,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]