guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using a module : rename a single definition


From: tomas
Subject: Re: using a module : rename a single definition
Date: Sun, 3 Mar 2024 13:55:49 +0100

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: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]