From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: when to #:replace
Date: Sun, 20 Jun 2010 23:29:35 +0200 [thread overview]
Message-ID: <87zkypv1ds.fsf@gnu.org> (raw)
In-Reply-To: m37hltcthg.fsf@pobox.com
Hi!
Andy Wingo <wingo@pobox.com> writes:
> Q: I have a module that overrides a core binding (like
> make-hash-table). Should I #:export that binding or #:replace it?
>
> A: #:replace. Presumably the user knows what she is doing when she
> uses your module. If she really cares she can change the duplicate
> bindings resolution mechanism to disallow such imports.
+1
But...
The manual currently says otherwise (info "(guile) Creating Guile
Modules"):
`#:replace LIST'
Export all identifiers in LIST (a list of symbols or pairs of
symbols) and mark them as "replacing bindings".
[...]
This is useful for modules that export bindings that have the
same name as core bindings. `#:replace', in a sense, lets
Guile know that the module _purposefully_ replaces a core
binding. It is important to note, however, that this binding
replacement is confined to the name space of the module user.
In other words, the value of the core binding in question
remains unchanged for other modules.
For instance, SRFI-39 exports a binding named
`current-input-port' (*note SRFI-39::) that is a function
which is upwardly compatible with the core
`current-input-port' function. Therefore, SRFI-39 exports
its version with `#:replace'.
SRFI-19, on the other hand, exports its own version of
`current-time' (*note SRFI-19 Time::) which is not compatible
with the core `current-time' function (*note Time::).
Therefore, SRFI-19 does not use `#:replace'.
According to your rationale, SRFI-19 would #:replace ‘current-time’.
(See also http://www.mail-archive.com/guile-devel@gnu.org/msg00479.html
and http://www.mail-archive.com/guile-devel@gnu.org/msg00469.html .)
Thanks,
Ludo’.
next prev parent reply other threads:[~2010-06-20 21:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-20 20:57 when to #:replace Andy Wingo
2010-06-20 21:29 ` Ludovic Courtès [this message]
2010-06-21 19:33 ` Andy Wingo
2010-06-21 21:54 ` Ludovic Courtès
2010-06-21 22:09 ` Andy Wingo
2010-07-17 11:31 ` Andy Wingo
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=87zkypv1ds.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=guile-devel@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).