unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: <tomas@tuxteam.de>
To: Damien Mattei <damien.mattei@gmail.com>
Cc: guile-user <guile-user@gnu.org>
Subject: Re: using a module : rename a single definition
Date: Sun, 3 Mar 2024 13:55:49 +0100	[thread overview]
Message-ID: <ZeRzVdOGd4pEkQzM@tuxteam.de> (raw)
In-Reply-To: <CADEOaddv-nDXFRXg6UfwOd70uEiwPTUR0ff09dxVZSzFvKAbYw@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]

On Sun, Mar 03, 2024 at 09:46:41AM +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:

I was under the impression that #:renamer should give us enough rope
to shoot anyone in the foot ;-)

A quick and unscientific test -- this one should rename xcons to snoc
and leave all the rest of srfi-1 alone:

  tomas@trotzki:~$ guile
  GNU Guile 3.0.9.120-79e836-dirty
  Copyright (C) 1995-2023 Free Software Foundation, Inc.
  scheme@(guile-user)> (use-modules ( (srfi srfi-1)
                                      #:renamer (lambda (sym)
                                                  (if (eq? sym 'xcons)
                                                        'snoc
                                                        sym))))
  
  scheme@(guile-user)> (snoc 'a 'b)
  $1 = (b . a)

Cheers
-- 
t

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  parent reply	other threads:[~2024-03-03 12:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-03  8:46 using a module : rename a single definition Damien Mattei
2024-03-03 11:50 ` Tomas Volf
2024-03-03 14:37   ` Damien Mattei
2024-03-03 12:55 ` tomas [this message]
2024-03-19 23:09 ` Maxime Devos
2024-03-27  7:42   ` Damien Mattei
2024-03-27 10:47     ` Hans-Werner Roitzsch
2024-03-27 11:44       ` Damien Mattei

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=ZeRzVdOGd4pEkQzM@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=damien.mattei@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).