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 v8 06/16] Share features tested by cond-expand library declarations and expressions. Date: Wed, 6 Dec 2023 18:15:02 -0500 Message-ID: <20231206231512.6505-7-maxim.cournoyer@gmail.com> References: <20231206231512.6505-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="725"; 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 Thu Dec 07 00:17:34 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 1rB192-000ASv-DZ for guile-devel@m.gmane-mx.org; Thu, 07 Dec 2023 00:17:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rB17V-0001wB-2n; Wed, 06 Dec 2023 18:15:57 -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 1rB17H-0001o3-Tm for guile-devel@gnu.org; Wed, 06 Dec 2023 18:15:45 -0500 Original-Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rB175-00017u-RZ for guile-devel@gnu.org; Wed, 06 Dec 2023 18:15:43 -0500 Original-Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-77f35009e78so3494885a.1 for ; Wed, 06 Dec 2023 15:15:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701904529; x=1702509329; 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=SrKaD4eg09pAk1IU3KnGcyKb7INZp9uUK1mI/bB9nUQ=; b=Qk46uKd5Po/H+JUf/Kjqor3s4aMhUFxVu8yCRHVoDOK+RVP9bXka1Z4Ubq5lhQL8or eoQaBJdSHe/605ISyAqr9NlLeCPw2TbrGs4ehFI6mXw8o9uKlduWC3p+1v7J0b5waFKL 1Q5iKgS4Z9sJ/6JYEMdJ8wVyaEKaed0xUxKU9agY30j5jY008TUV9CJVWSTlIbdg4miZ E964aYA2cWVTUZBT7T2euNQbCKv+1o+TMTfe2YNjJNAL24Ta1TU7GKd4Hm7KSnjG3rlj iq1d8FF4vwsbAmt2uREdtF2ln9UN31XrPQeZp41Za7Vaf6mt278/OUoqIH6bOkxUTFnC h1XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701904529; x=1702509329; 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=SrKaD4eg09pAk1IU3KnGcyKb7INZp9uUK1mI/bB9nUQ=; b=VPLbbLW0TFqRLs248INgsb4sNV9cAkb7a9WqpMxIhcNi9PPLE3p2Od8ndhzTAdhsoR VMfq5+uOP6AMvPgdh+y6ZnHPnfi6yajotV75v4WqGONlREbYh7fpNC891S5AzUrHuhIV Um3bg/VIBVVDrOiukGTcjWU5XE3WP00hVWEzWoqrP/s9c6xFRQZVH/9QkxJ/jvMhGOuD LL6i/yTh0GqMKrewn8F4cVQpTjpd6YwpCwfidTa+O/cqJsdFwYcDHxkaezNRlVBlwQDQ ijFLzsQnr8wWxlzs6a4guQcu3H6aAf4gPDVEKm3AH894vxpQwSd4QT2kgffxcrk2Uyq2 4szw== X-Gm-Message-State: AOJu0YzzFuaB8ZH6ZHuTkXrW4tDU5CVlRY8Ck4842Dqb5B6CeT1Dp3sz SuMY8kgfWFtn5VjSJoX6U25Ia2iaui8= X-Google-Smtp-Source: AGHT+IGBlFv2UtNHiZEVYZrG4jmB2SoY5cQLbEqi0Q11eYhty7c/3pDqYaABWuYKzO6YkL+2++r0ow== X-Received: by 2002:a05:620a:8888:b0:77f:3b37:a75f with SMTP id qk8-20020a05620a888800b0077f3b37a75fmr239161qkn.133.1701904529113; Wed, 06 Dec 2023 15:15:29 -0800 (PST) Original-Received: from localhost.localdomain (dsl-10-130-68.b2b2c.ca. [72.10.130.68]) by smtp.gmail.com with ESMTPSA id re18-20020a05620a8e1200b0077d8ad77069sm3400qkn.26.2023.12.06.15.15.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 15:15:28 -0800 (PST) X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231206231512.6505-1-maxim.cournoyer@gmail.com> Received-SPF: pass client-ip=2607:f8b0:4864:20::734; envelope-from=maxim.cournoyer@gmail.com; helo=mail-qk1-x734.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, 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:22222 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. --- (no changes since v5) 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