[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using a module : rename a single definition
From: |
Tomas Volf |
Subject: |
Re: using a module : rename a single definition |
Date: |
Sun, 3 Mar 2024 12:50:09 +0100 |
On 2024-03-03 09:46:41 +0100, Damien Mattei wrote:
> hello,
>
> is it possible to import a module having just one variable renamed (not
> all) , as in Racket:
>
> (require (rename-in srfi/42
> (: s42:))) ; Eager Comprehensions
>
> it seems in Guile either all is imported and prefixed or only a selection
> of bindings can be imported:
>
> https://www.gnu.org/software/guile/manual/html_node/Using-Guile-Modules.html
>
> (use-modules ((ice-9 popen)
> #:select ((open-pipe . pipe-open) close-pipe)
> #:prefix unixy:))
>
> regards,
There does not seem to be a way to *exclude* a single symbol from the import,
but, if you do not mind having *also* the original symbol (or if you will just
override it later with something else anyway), it seems you can do something
like this:
(use-modules (ice-9 popen)
((ice-9 popen) #:select ((open-pipe . foo-bar))))
After that you have both `open-pipe' and `foo-bar' available, pointing to the
same procedure. At this point you could just re-define `open-pipe' to something
else and use the `foo-bar'.
Maybe there is a better way, but I did not find it in the manual.
Have a nice day,
Tomas Volf
--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
signature.asc
Description: PGP signature