From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: "guile-user@gnu.org" <guile-user@gnu.org>
Subject: Weird module behaviour
Date: Thu, 25 Sep 2014 16:04:06 +0200 [thread overview]
Message-ID: <CAMFYt2ZP+iBN=wFVNwPt_J_FKdNvMB_jHQA0UbmbPbUjaepacw@mail.gmail.com> (raw)
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.
next reply other threads:[~2014-09-25 14:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-25 14:04 Panicz Maciej Godek [this message]
2014-09-25 14:25 ` Weird module behaviour 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMFYt2ZP+iBN=wFVNwPt_J_FKdNvMB_jHQA0UbmbPbUjaepacw@mail.gmail.com' \
--to=godek.maciek@gmail.com \
--cc=guile-user@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).