unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Damien Mattei <damien.mattei@gmail.com>
To: Damien Mattei <damien.mattei@gmail.com>, guile-user <guile-user@gnu.org>
Subject: Re: using a module : rename a single definition
Date: Sun, 3 Mar 2024 15:37:02 +0100	[thread overview]
Message-ID: <CADEOadev44J5U2jS-FfFKnbGWr0cTpR_CoExW224JScmVrdL=g@mail.gmail.com> (raw)
In-Reply-To: <ZeRj8fB0JKk5QmT2@ws>

yes , your solution works, thanks :

(use-modules (Scheme+)
    (matrix+)
    (srfi srfi-42) ; import all definitions
    ((srfi srfi-42)
            #:select ((: . s42-:))) ; rename only one
    ;;((srfi srfi-42) ; Eager Comprehensions
    ;; #:prefix s42-)
    (oop goops)
    (srfi srfi-43)) ; vectors

used in code:

{M <- (vector-ec (s42-: n {lnc - 1}) ; vectors by eager comprehension (SRFI
42)
                            create-matrix-by-function(uniform-dummy nc[n +
1] {nc[n] + 1}))} ;; Matrix-vect

after parsing (convert curly infix scheme+ to classic scheme):

(<- M
      (vector-ec
        (s42-: n (- lnc 1))
        (create-matrix-by-function
          uniform-dummy
          ($bracket-apply$next nc (list (+ n 1)))
          (+ ($bracket-apply$next nc (list n)) 1))))

i tested also the solution of tomas and it works too:

(use-modules (Scheme+)
    (matrix+)
    ;(srfi srfi-42) ; import all definitions
             ((srfi srfi-42)
#:renamer (lambda (sym)
                              (if (eq? sym ':)
                                  's42-:
                                  sym)))
;#:select ((: . s42-:))) ; rename only one
    ;;((srfi srfi-42) ; Eager Comprehensions
;; #:prefix s42-)
    (oop goops)
    (srfi srfi-43)) ; vectors

Merçi

Damien

On Sun, Mar 3, 2024 at 12:50 PM Tomas Volf <~@wolfsden.cz> wrote:

> 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.
>


  reply	other threads:[~2024-03-03 14:37 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 [this message]
2024-03-03 12:55 ` tomas
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='CADEOadev44J5U2jS-FfFKnbGWr0cTpR_CoExW224JScmVrdL=g@mail.gmail.com' \
    --to=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).