unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: Timothy Sample <samplet@ngyro.com>
Cc: 67255@debbugs.gnu.org
Subject: bug#67255: define-library does not support 'rename' directives
Date: Wed, 22 Nov 2023 22:57:32 -0500	[thread overview]
Message-ID: <87y1ep86kz.fsf@gmail.com> (raw)
In-Reply-To: <87cyw42vpv.fsf@ngyro.com> (Timothy Sample's message of "Mon, 20 Nov 2023 11:14:20 -0600")

Hello!

Timothy Sample <samplet@ngyro.com> writes:

> Timothy Sample <samplet@ngyro.com> writes:
>
>> Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
>>
>>> Our R7RS define-library syntax, from (ice-9 r7rs-library) does not
>>> support renaming bindings to export, via 'rename' directives.
>>
>> I appreciate your R7RS debugging effort.  Thanks!
>
> Actions speak louder than words, so here’s a patch!
>
> The ‘define-library’ syntax uses the R6RS ‘library’ syntax under the
> hood.  TIL that R6RS and R7RS have different syntax for 'rename'.  In
> R6RS, you write:
>
>     (export (rename (internal external)))
>
> while in R7RS, it’s:
>
>     (export (rename internal external))
>
> My patch adds a conversion step to deal with this difference.

Oh, excellent, thank you!

>>From b87bf8910ac8e75dc0ec63cb7385ddf199fd400c Mon Sep 17 00:00:00 2001
> From: Timothy Sample <samplet@ngyro.com>
> Date: Mon, 20 Nov 2023 11:01:08 -0600
> Subject: [PATCH] Use R7RS 'rename' syntax for exports.
>
> Fixes <https://bugs.gnu.org/67255>.
> Reported by Maxim Cournoyer <maxim.cournoyer@gmail.com>.

Nitpick: at least 'Reported-by' is a common git trailer, and these
must appear at the bottom of the git commit.

> * module/ice-9/r7rs-libraries.scm (define-library): Convert R7RS
> exports to R6RS exports before passing them on to 'library'.
> ---
>  module/ice-9/r7rs-libraries.scm | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/module/ice-9/r7rs-libraries.scm b/module/ice-9/r7rs-libraries.scm
> index 63a300a26..f8b6b4c59 100644
> --- a/module/ice-9/r7rs-libraries.scm
> +++ b/module/ice-9/r7rs-libraries.scm
> @@ -1,5 +1,5 @@
>  ;; R7RS library support
> -;;      Copyright (C) 2020, 2021 Free Software Foundation, Inc.
> +;;      Copyright (C) 2020, 2021, 2023 Free Software Foundation, Inc.
>  ;;
>  ;; This library is free software; you can redistribute it and/or
>  ;; modify it under the terms of the GNU Lesser General Public
> @@ -97,12 +97,17 @@
>             ((decl ...)
>              (partition-decls #'(decl ... . decls) exports imports code))))))
>  
> +    (define (r7rs-export->r6rs-export export)
> +      (syntax-case export (rename)
> +        ((rename internal external) #'(rename (internal external)))
> +        (_ export)))
> +
>      (syntax-case stx ()
>        ((_ name decl ...)
>         (call-with-values (lambda ()
>                             (partition-decls #'(decl ...) '() '() '()))
>           (lambda (exports imports code)
>             #`(library name
> -               (export . #,exports)
> +               (export . #,(map r7rs-export->r6rs-export exports))
>                 (import . #,imports)
>                 . #,code)))))))

It at least works for my use case (SRFI 128), so it's for sure an
improvement :-).  You can see it in action in the series I've sent today.

-- 
Thanks,
Maxim





  reply	other threads:[~2023-11-23  3:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-18  5:46 bug#67255: define-library does not support 'rename' directives Maxim Cournoyer
2023-11-20 15:53 ` Timothy Sample
2023-11-20 17:14   ` Timothy Sample
2023-11-23  3:57     ` Maxim Cournoyer [this message]
2023-11-23 16:12       ` Timothy Sample
2023-11-24 21:01 ` bug#67255: [PATCH v2] Use R7RS 'rename' syntax for exports Maxim Cournoyer

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=87y1ep86kz.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=67255@debbugs.gnu.org \
    --cc=samplet@ngyro.com \
    /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).