unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: guile-devel@gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [PATCH v8 05/16] (scheme base): Support non-negative SRFI integer names in cond-expand.
Date: Wed,  6 Dec 2023 18:15:01 -0500	[thread overview]
Message-ID: <20231206231512.6505-6-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <20231206231512.6505-1-maxim.cournoyer@gmail.com>

* module/scheme/base.scm (r7:cond-expand): Test for library using
resolve-r6rs-interface instead of resolve-interface.  Swallow any
exception with false-if-exception.
* test-suite/tests/r7rs-cond-expand.test: New test.
* NEWS: Update news.

---

(no changes since v5)

Changes in v5:
 - Update NEWS

 NEWS                                   |  1 +
 module/scheme/base.scm                 |  5 +++-
 test-suite/tests/r7rs-cond-expand.test | 35 ++++++++++++++++++++++++++
 3 files changed, 40 insertions(+), 1 deletion(-)
 create mode 100644 test-suite/tests/r7rs-cond-expand.test

diff --git a/NEWS b/NEWS
index af66c80bd..1de1fa8b4 100644
--- a/NEWS
+++ b/NEWS
@@ -55,6 +55,7 @@ other operations, given the internal use of those functions.
    (<https://bugs.gnu.org/66046>)
 ** R7RS define-library now properly supports 'rename' declarations
    (<https://bugs.gnu.org/67255>)
+** (scheme base)'s cond-expand supports non-negative integer in modules names
 
 \f
 Changes in 3.0.9 (since 3.0.8)
diff --git a/module/scheme/base.scm b/module/scheme/base.scm
index 477dd9c28..2bd1f0d89 100644
--- a/module/scheme/base.scm
+++ b/module/scheme/base.scm
@@ -283,7 +283,10 @@
         ((not req)
          (not (has-req? #'req)))
         ((library lib-name)
-         (->bool (resolve-interface (syntax->datum #'lib-name))))
+         (->bool
+          (false-if-exception
+           (resolve-r6rs-interface
+            (syntax->datum #'lib-name)))))
         (id
          (identifier? #'id)
          (memq (syntax->datum #'id) (features)))))
diff --git a/test-suite/tests/r7rs-cond-expand.test b/test-suite/tests/r7rs-cond-expand.test
new file mode 100644
index 000000000..ea880d8c2
--- /dev/null
+++ b/test-suite/tests/r7rs-cond-expand.test
@@ -0,0 +1,35 @@
+;;; R7RS cond-expand     -*- scheme -*-
+;;; Copyright (C) 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 License as
+;;; published by the Free Software Foundation, either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; This library is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;;; Lesser General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Lesser General Public
+;;; License along with this program.  If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+(define-module (test-suite r7rs-cond-expand)
+  #:use-module ((scheme base) #:select (cond-expand))
+  #:use-module ((srfi srfi-64) #:select (test-read-eval-string))
+  #:use-module (test-suite lib))
+
+(pass-if "cond-expand expression missing library test"
+  (test-read-eval-string "\
+(cond-expand
+ ((library (srfi 99999 something))
+  #f)
+ (else #t))"))
+
+(pass-if "cond-expand expression found library test"
+  (test-read-eval-string "\
+(cond-expand
+ ((library (srfi 64))
+  #t)
+ (else #f))"))
-- 
2.41.0




  parent reply	other threads:[~2023-12-06 23:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-06 23:14 [PATCH v8 00/16] Add SRFI 209 and dependencies; improve support for R7RS libraries Maxim Cournoyer
2023-12-06 23:14 ` [PATCH v8 01/16] ice-9: Fix 'include' when used in compilation contexts Maxim Cournoyer
2023-12-06 23:14 ` [PATCH v8 02/16] Use R7RS 'rename' syntax for exports Maxim Cournoyer
2023-12-06 23:14 ` [PATCH v8 03/16] r7rs-libraries: Add support for 'else' clause in cond-expand Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 04/16] r7rs-libraries: Better support R7RS SRFI library names Maxim Cournoyer
2023-12-06 23:15 ` Maxim Cournoyer [this message]
2023-12-06 23:15 ` [PATCH v8 06/16] Share features tested by cond-expand library declarations and expressions Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 07/16] build: Register '.sld' as an alternative extension to '.scm' Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 08/16] module: Add SRFI 126 Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 09/16] module: Add SRFI 128 Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 10/16] module: Add (scheme comparator) Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 11/16] module: Add (scheme sort) Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 12/16] module: Add SRFI 125 Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 13/16] module: Add SRFI 151 Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 14/16] module: Add SRFI 160 Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 15/16] module: Add SRFI 178 Maxim Cournoyer
2023-12-06 23:15 ` [PATCH v8 16/16] module: Add SRFI 209 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=20231206231512.6505-6-maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=guile-devel@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).