From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxim Cournoyer Newsgroups: gmane.lisp.guile.bugs Subject: bug#67255: define-library does not support 'rename' directives Date: Wed, 22 Nov 2023 22:57:32 -0500 Message-ID: <87y1ep86kz.fsf@gmail.com> References: <87r0knbome.fsf@gmail.com> <87a5r84e1l.fsf@ngyro.com> <87cyw42vpv.fsf@ngyro.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="14468"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 67255@debbugs.gnu.org To: Timothy Sample Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Thu Nov 23 04:58:14 2023 Return-path: Envelope-to: guile-bugs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r60qz-0003Xb-Ol for guile-bugs@m.gmane-mx.org; Thu, 23 Nov 2023 04:58:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r60qn-0003yc-2S; Wed, 22 Nov 2023 22:58:01 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r60qk-0003y6-Kf for bug-guile@gnu.org; Wed, 22 Nov 2023 22:57:59 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r60qk-0006dY-C7 for bug-guile@gnu.org; Wed, 22 Nov 2023 22:57:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r60qn-0004Y5-UR for bug-guile@gnu.org; Wed, 22 Nov 2023 22:58:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Thu, 23 Nov 2023 03:58:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67255 X-GNU-PR-Package: guile Original-Received: via spool by 67255-submit@debbugs.gnu.org id=B67255.170071186817465 (code B ref 67255); Thu, 23 Nov 2023 03:58:01 +0000 Original-Received: (at 67255) by debbugs.gnu.org; 23 Nov 2023 03:57:48 +0000 Original-Received: from localhost ([127.0.0.1]:60314 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r60qZ-0004Xd-O7 for submit@debbugs.gnu.org; Wed, 22 Nov 2023 22:57:48 -0500 Original-Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]:50523) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r60qX-0004XO-7j for 67255@debbugs.gnu.org; Wed, 22 Nov 2023 22:57:46 -0500 Original-Received: by mail-qt1-x831.google.com with SMTP id d75a77b69052e-42135f8e08fso2417251cf.1 for <67255@debbugs.gnu.org>; Wed, 22 Nov 2023 19:57:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700711855; x=1701316655; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=YuhH+YSy4fj+SD/I2b5+tY6GC+CAyC1pud0sOfj/Mao=; b=GZKHAXOkdjaD3YVAGcT1ETy3Pd124y64ooP+G+etSI+k3zLOL1w+jp4mf5qtAJWQgM y3SgsKR8uradpnp48EaVa/i1lKd6b1V3RQ5VCy43IQZdFVL5d349iAqj/QtSOOtOz+J9 o63lDAGu0DU7MCe7JAO4uUvhb7mGB1lmOv4EeATcWmz6MO69siP7PxyO+m/NL03uJad5 bjZ+WlphyCIpRoWO3+qRvYrfCCs4/M4sohfOdXbD0+jVE1jiMov61KZaaryeUhd0jlJD O3kXdGE+9f7VbyLgNdVZXol2bAWBPFvU5jrzeUo/Yu9hGQEluKZqKeo2PmbRcTjDFFgz XG+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700711855; x=1701316655; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=YuhH+YSy4fj+SD/I2b5+tY6GC+CAyC1pud0sOfj/Mao=; b=O91gEi6ePLOWHYxKYjTMgan/Zu07dMz1LAJlxQ/LN5iPWJ1PfNHNXwRWyegta7K0su RX0ta7RpJKV7FGVcg7EE56yyxtYAiQijWxwhfHQSPMxDmjI7nXqQLdRI43T0wnY5Vdue LFQFjakJ1JsIhjlUS1nNogM1vV3rKxn96C3lhndFX4RR1n/+8NwchviVEDXviOYt8/jj NU3b1rSbJ6b/TjENZHfSHj8T7EBTYhySCH2Ey6WY7tE9e4Ddpoj6B1UzT9x8kMemPErE 1SKcXCj1B2hePRuZHagCOEKa1mjsPDF1DWZowTogcPYk0DOqy5dN/2Xcan6fq+28InwS ZEYg== X-Gm-Message-State: AOJu0Yy24Yn4xzLglrENniV0B/TGXBzNiGEnlI6Br3rbFLhNcHynXWP2 2HEEdCwV2ZYbYiwf32EKu4eBNGMNz9w= X-Google-Smtp-Source: AGHT+IFBqE55rIhq510PcCZwLJzyU7RhXyLrYpj5xewPjzsGMJ6wAIXHHJ36DaSBU94pg/xeM2V2rA== X-Received: by 2002:ac8:4e54:0:b0:423:7294:89aa with SMTP id e20-20020ac84e54000000b00423729489aamr5694138qtw.42.1700711853522; Wed, 22 Nov 2023 19:57:33 -0800 (PST) Original-Received: from hurd (dsl-205-233-124-102.b2b2c.ca. [205.233.124.102]) by smtp.gmail.com with ESMTPSA id t2-20020ac87602000000b00421c272bcbasm162907qtq.11.2023.11.22.19.57.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 19:57:33 -0800 (PST) In-Reply-To: <87cyw42vpv.fsf@ngyro.com> (Timothy Sample's message of "Mon, 20 Nov 2023 11:14:20 -0600") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.bugs:10712 Archived-At: Hello! Timothy Sample writes: > Timothy Sample writes: > >> Maxim Cournoyer 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=E2=80=99s a patch! > > The =E2=80=98define-library=E2=80=99 syntax uses the R6RS =E2=80=98librar= y=E2=80=99 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=E2=80=99s: > > (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 > Date: Mon, 20 Nov 2023 11:01:08 -0600 > Subject: [PATCH] Use R7RS 'rename' syntax for exports. > > Fixes . > Reported by Maxim Cournoyer . 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-librarie= s.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))= )))) >=20=20 > + (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. --=20 Thanks, Maxim