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.devel Subject: [PATCH v5 06/15] Share features tested by cond-expand library declarations and expressions. Date: Wed, 29 Nov 2023 16:59:34 -0500 Message-ID: <20231129220225.6819-7-maxim.cournoyer@gmail.com> References: <20231129220225.6819-1-maxim.cournoyer@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11665"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Maxim Cournoyer To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Wed Nov 29 23:03:57 2023 Return-path: Envelope-to: guile-devel@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 1r8Sez-0002mb-86 for guile-devel@m.gmane-mx.org; Wed, 29 Nov 2023 23:03:57 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8Se4-0001Bs-NH; Wed, 29 Nov 2023 17:03:00 -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 1r8Sdz-0001AG-1H for guile-devel@gnu.org; Wed, 29 Nov 2023 17:02:55 -0500 Original-Received: from mail-oi1-x22e.google.com ([2607:f8b0:4864:20::22e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r8Sdu-0004D0-T0 for guile-devel@gnu.org; Wed, 29 Nov 2023 17:02:54 -0500 Original-Received: by mail-oi1-x22e.google.com with SMTP id 5614622812f47-3b898c9b4cbso159094b6e.2 for ; Wed, 29 Nov 2023 14:02:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701295368; x=1701900168; darn=gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h7U+QoaDIusiZ5gRE1UZ98LL9n7Cn+bTnVbtBXDMnnE=; b=fESegxwGk3s9XLevkBMtvVdMajC40xt2UQk19xwYdDmlLbPJ/d+ObphFSSybhHbEdA 6MTu3E7nHhXIs4OWoE+Nq/wmYY5iU8O4O9fpKc6Z5JzQvjQkHm1UV3OSrm94tGMbTRt6 ECOg4a9+hniHITaXXw+k0PPQ77eybGFtYR8iGFM5P8w0tkz6qJ4aUbC7ian85E4n73LS /lnJfetIRCUCH366hXy4VwPFMs+c2aH30ekezLX2CEw1QkgPSu/HFSVSUxSt+VEQOLIX SdMolm19aBSithjdtI9zbTLTCMQZWLTxnWsn/N2Y61SzuKpWJpc8bv2UqGhN9KTd2cu9 4eIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701295368; x=1701900168; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h7U+QoaDIusiZ5gRE1UZ98LL9n7Cn+bTnVbtBXDMnnE=; b=rAzDsmfsElji1XE3LWIwI4KucK5WGWlcGh+mOndGD6usfjqyZGEhZ5LeuVSOCxandc t551LTr8bAdx1quX+7pNAmIg8B3FPv8162vDDrBF1TCB7E3cFtuP6g+FOjHH4jaZ2cep D/drC5XQwGV4LunIR4olqUSbs8/rYqNXXJiDlJG1rEpelIeNQL+huj1T7Hhf/Y5Obn3j PVIpi99d0pVdwOXCQo3GiCV2/Ecxp7yOJ2SVViYwL38tLw0MYa0wxExu3HJleid8HOBd DuUxhNgEnqZAb2lHmcL81gK6iCo3k4k1uCMr6xWaF1MzMh77M1wzt7BqkyJ1BSmt477d KTlg== X-Gm-Message-State: AOJu0Yy/SXqNULZBD/cKIUUP/hE6guAlh6w+aAHPZb3OnaEEG8lZnzrB 2agIkAPaqrOBEWRMkM5RpVsQQYKnjrI= X-Google-Smtp-Source: AGHT+IFV9jFqmzZrkNqQmqWXZhNLXbQ6vjuLVrxXRUwJl6GdfMdoz9IxC+czwOxOdhgROUbm1zcu1A== X-Received: by 2002:a05:6808:10d2:b0:3af:d955:261a with SMTP id s18-20020a05680810d200b003afd955261amr25199526ois.7.1701295368282; Wed, 29 Nov 2023 14:02:48 -0800 (PST) Original-Received: from localhost.localdomain (dsl-158-174.b2b2c.ca. [66.158.158.174]) by smtp.gmail.com with ESMTPSA id g15-20020ad4510f000000b0067a2a0b44ddsm4644444qvp.44.2023.11.29.14.02.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 14:02:48 -0800 (PST) X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231129220225.6819-1-maxim.cournoyer@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::22e; envelope-from=maxim.cournoyer@gmail.com; helo=mail-oi1-x22e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:22143 Archived-At: This addresses a FIXME in r7rs-libraries.scm, which was about the cond-expand define-library declarations not using the same features as provided in (scheme base). * .gitignore: Register /module/ice-9/endianness.scm. * am/bootstrap.am (NOCOMP_SOURCES): Register ice-9/endianness.scm and scheme/features.scm. * configure.ac: Define a NATIVE_ENDIANNESS output variable. * module/ice-9/endianness.scm.in: New file. * module/scheme/base.scm (features): Move to... * module/scheme/features.scm: ... here. Include this file in base.scm and... * module/ice-9/r7rs-libraries.scm: ... here. (define-library) : Adjust to match the definition of cond-expand found in (scheme base). * module/ice-9/boot-9.scm (%cond-expand-features): Move before where r7rs-libraries.scm is included. * NEWS: Update NEWS. --- Changes in v5: - Update NEWS .gitignore | 1 + NEWS | 1 + am/bootstrap.am | 2 ++ configure.ac | 7 +++- module/ice-9/boot-9.scm | 62 +++++++++++++++++---------------- module/ice-9/endianness.scm.in | 1 + module/ice-9/r7rs-libraries.scm | 6 ++-- module/scheme/base.scm | 10 ++---- module/scheme/features.scm | 44 +++++++++++++++++++++++ 9 files changed, 92 insertions(+), 42 deletions(-) create mode 100644 module/ice-9/endianness.scm.in create mode 100644 module/scheme/features.scm diff --git a/.gitignore b/.gitignore index 931ebf7c4..7903bee15 100644 --- a/.gitignore +++ b/.gitignore @@ -122,6 +122,7 @@ INSTALL /meta/guild /meta/guile-config /lib/locale.h +/module/ice-9/endianness.scm /module/ice-9/eval.go.stamp /doc/ref/standard-library.texi /doc/ref/standard-libraryscmfiles diff --git a/NEWS b/NEWS index 1de1fa8b4..e5cc3c7aa 100644 --- a/NEWS +++ b/NEWS @@ -56,6 +56,7 @@ other operations, given the internal use of those functions. ** R7RS define-library now properly supports 'rename' declarations () ** (scheme base)'s cond-expand supports non-negative integer in modules names +** define-library's cond-expand declarations can now test complete features Changes in 3.0.9 (since 3.0.8) diff --git a/am/bootstrap.am b/am/bootstrap.am index a71946958..39f65f100 100644 --- a/am/bootstrap.am +++ b/am/bootstrap.am @@ -427,12 +427,14 @@ ELISP_SOURCES = \ language/elisp/boot.el NOCOMP_SOURCES = \ + ice-9/endianness.scm \ ice-9/match.upstream.scm \ ice-9/psyntax.scm \ ice-9/read.scm \ ice-9/r6rs-libraries.scm \ ice-9/r7rs-libraries.scm \ ice-9/quasisyntax.scm \ + scheme/features.scm \ srfi/srfi-42/ec.scm \ srfi/srfi-64/testing.scm \ srfi/srfi-67/compare.scm \ diff --git a/configure.ac b/configure.ac index d0a2dc79b..d049a5a1b 100644 --- a/configure.ac +++ b/configure.ac @@ -326,7 +326,12 @@ else fi AC_CHECK_LIB(uca, __uc_get_ar_bsp) -AC_C_BIGENDIAN +AC_C_BIGENDIAN( + [AC_DEFINE([WORDS_BIGENDIAN], 1) + AC_SUBST([NATIVE_ENDIANNESS], [big])], + [AC_SUBST([NATIVE_ENDIANNESS], [little])] +) +AC_CONFIG_FILES([module/ice-9/endianness.scm]) AC_C_LABELS_AS_VALUES diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index a79d49ae1..3da328b2a 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -4066,6 +4066,38 @@ but it fails to load." (process-use-modules (list quoted-args ...)) *unspecified*)))))) +;;; This is defined early because ice-9/r7rs-libraries makes use of +;;; the R7RS features, which requires it to be defined. +(define %cond-expand-features + ;; This should contain only features that are present in core Guile, + ;; before loading any modules. Modular features are handled by + ;; placing 'cond-expand-provide' in the relevant module. + '(guile + guile-2 + guile-2.2 + guile-3 + guile-3.0 + r5rs + r6rs + r7rs + exact-closed ieee-float full-unicode ratios ;; R7RS features. + srfi-0 ;; cond-expand itself + srfi-4 ;; homogeneous numeric vectors + srfi-6 ;; string ports + srfi-13 ;; string library + srfi-14 ;; character sets + srfi-16 ;; case-lambda + srfi-23 ;; `error` procedure + srfi-30 ;; nested multi-line comments + srfi-39 ;; parameterize + srfi-46 ;; basic syntax-rules extensions + srfi-55 ;; require-extension + srfi-61 ;; general cond clause + srfi-62 ;; s-expression comments + srfi-87 ;; => in case clauses + srfi-105 ;; curly infix expressions + )) + (include-from-path "ice-9/r6rs-libraries") (include-from-path "ice-9/r7rs-libraries") @@ -4535,36 +4567,6 @@ when none is available, reading FILE-NAME with READER." ;;; Remember to update the features list when adding more SRFIs. ;;; -(define %cond-expand-features - ;; This should contain only features that are present in core Guile, - ;; before loading any modules. Modular features are handled by - ;; placing 'cond-expand-provide' in the relevant module. - '(guile - guile-2 - guile-2.2 - guile-3 - guile-3.0 - r5rs - r6rs - r7rs - exact-closed ieee-float full-unicode ratios ;; R7RS features. - srfi-0 ;; cond-expand itself - srfi-4 ;; homogeneous numeric vectors - srfi-6 ;; string ports - srfi-13 ;; string library - srfi-14 ;; character sets - srfi-16 ;; case-lambda - srfi-23 ;; `error` procedure - srfi-30 ;; nested multi-line comments - srfi-39 ;; parameterize - srfi-46 ;; basic syntax-rules extensions - srfi-55 ;; require-extension - srfi-61 ;; general cond clause - srfi-62 ;; s-expression comments - srfi-87 ;; => in case clauses - srfi-105 ;; curly infix expressions - )) - ;; This table maps module public interfaces to the list of features. ;; (define %cond-expand-table (make-hash-table)) diff --git a/module/ice-9/endianness.scm.in b/module/ice-9/endianness.scm.in new file mode 100644 index 000000000..5d3f5dbaa --- /dev/null +++ b/module/ice-9/endianness.scm.in @@ -0,0 +1 @@ +(define %native-endianness '@NATIVE_ENDIANNESS@) diff --git a/module/ice-9/r7rs-libraries.scm b/module/ice-9/r7rs-libraries.scm index 773a9d47b..20692989d 100644 --- a/module/ice-9/r7rs-libraries.scm +++ b/module/ice-9/r7rs-libraries.scm @@ -29,6 +29,8 @@ (define-syntax-rule (include-ci filename) (include filename)) +(include-from-path "scheme/features.scm") + (define-syntax define-library (lambda (stx) (define (r7rs-module-name->r6rs-module-name name) @@ -91,9 +93,7 @@ (syntax->datum #'lib-name))))) (id (identifier? #'id) - ;; FIXME: R7RS (features) isn't quite the same as - ;; %cond-expand-features; see scheme/base.scm. - (memq (syntax->datum #'id) %cond-expand-features)))) + (memq (syntax->datum #'id) (features))))) (syntax-case clauses (else) (() #'()) ; R7RS says this is not specified :-/ (((else decl ...)) diff --git a/module/scheme/base.scm b/module/scheme/base.scm index 2bd1f0d89..1f47f8560 100644 --- a/module/scheme/base.scm +++ b/module/scheme/base.scm @@ -272,6 +272,8 @@ (make-exception exn (make-exception-with-irritants irritants)))))) +(include-from-path "scheme/features.scm") + (define-syntax r7:cond-expand (lambda (x) (define (has-req? req) @@ -551,14 +553,6 @@ (exact->inexact (expt x y)) (expt x y))) -(define (features) - (append - (case (native-endianness) - ((big) '(big-endian)) - ((little) '(little-endian)) - (else '())) - %cond-expand-features)) - (define (input-port-open? port) (and (not (port-closed? port)) (input-port? port))) diff --git a/module/scheme/features.scm b/module/scheme/features.scm new file mode 100644 index 000000000..7acbe332b --- /dev/null +++ b/module/scheme/features.scm @@ -0,0 +1,44 @@ +;;; R7RS compatibility libraries -- features +;;; Copyright (C) 2019-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 +;;; . + +;;; Based on code from https://gitlab.com/akku/akku-scm, written +;;; 2018-2019 by Göran Weinholt , as well as +;;; https://github.com/okuoku/yuni, written 2014-2018 by OKUMURA Yuki +;;; . This code was originally released under the +;;; following terms: +;;; +;;; To the extent possible under law, the author(s) have dedicated +;;; all copyright and related and neighboring rights to this +;;; software to the public domain worldwide. This software is +;;; distributed without any warranty. +;;; +;;; See , for a +;;; copy of the CC0 Public Domain Dedication. + +;;; This code is shared between (scheme base) and (ice-9 +;;; r7rs-libraries), which gets included in (ice-9 boot-9), to avoid +;;; having multiple copies 'features' to maintain. + +(include-from-path "ice-9/endianness.scm") + +(define (features) + (append + (case %native-endianness + ((big) '(big-endian)) + ((little) '(little-endian)) + (else '())) + %cond-expand-features)) -- 2.41.0