[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: when to #:replace
From: |
Ludovic Courtès |
Subject: |
Re: when to #:replace |
Date: |
Sun, 20 Jun 2010 23:29:35 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) |
Hi!
Andy Wingo <address@hidden> 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/address@hidden/msg00479.html
and http://www.mail-archive.com/address@hidden/msg00469.html .)
Thanks,
Ludo’.