From 36ba0aa655f0224687bc083f21cda9600bde9703 Mon Sep 17 00:00:00 2001 From: Rob Browning Date: Sun, 13 Apr 2025 17:35:53 -0500 Subject: [PATCH] Convert srfi-197 implementation and tests to modules https://srfi.schemers.org/srfi-197/srfi-197.html * NEWS: mention SRFI 197 support. * am/bootstrap.am: Add srfi-197.scm. * module/srfi/srfi-197.scm: Convert to module. * test-suite/Makefile.am: Add srfi-197.sr64. * test-suite/tests/srfi-197.sr64: Renamed from srfi-197.test. * test-suite/tests/srfi-197.test: Port to Guile; rename to srfi-197.sr64. --- NEWS | 5 +++++ am/bootstrap.am | 1 + module/srfi/srfi-197.scm | 18 +++++++++++++++--- test-suite/Makefile.am | 1 + .../tests/{srfi-197.test => srfi-197.sr64} | 17 ++++++++++++++++- 5 files changed, 38 insertions(+), 4 deletions(-) rename test-suite/tests/{srfi-197.test => srfi-197.sr64} (95%) diff --git a/NEWS b/NEWS index b4a705231..cbfcd8b35 100644 --- a/NEWS +++ b/NEWS @@ -22,6 +22,11 @@ downright unusable (e.g., ), non-conforming * New interfaces and functionality +** Guile now supports SRFI-197 (Pipeline Operators) + +Guile now provides chain, chain-and, chain-when, chain-lambda, nest, and +nest-reverse. + ** PEG parser PEG grammar parser in (ice-9 peg string-peg) has been rewritten to cover diff --git a/am/bootstrap.am b/am/bootstrap.am index 96023d83d..8faed0934 100644 --- a/am/bootstrap.am +++ b/am/bootstrap.am @@ -351,6 +351,7 @@ SOURCES = \ srfi/srfi-171.scm \ srfi/srfi-171/gnu.scm \ srfi/srfi-171/meta.scm \ + srfi/srfi-197.scm \ \ statprof.scm \ \ diff --git a/module/srfi/srfi-197.scm b/module/srfi/srfi-197.scm index bd52dac16..22b43071d 100644 --- a/module/srfi/srfi-197.scm +++ b/module/srfi/srfi-197.scm @@ -1,3 +1,5 @@ +;;;; srfi-197.scm --- SRFI 197: Pipeline Operators + ;;;; SPDX-FileCopyrightText: 2020 Adam R. Nelson ;;;; ;;;; SPDX-License-Identifier: MIT @@ -26,9 +28,19 @@ ;;;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ;;;; SOFTWARE. -; A syntax-case implementation of SRFI 197. -; This should be functionally equivalent to srfi-197.scm, -; but it may be easier to read and understand. +;;; Commentary: +;;; +;;; This is an implementation of SRFI 197: Pipeline Operators taken from +;;; the reference implementation's srfi-197-syntax-case.scm. +;;; +;;; Code: + +(define-module (srfi srfi-197) + #:use-module ((scheme base) #:select (eof-object let-values)) + #:use-module (srfi srfi-2) + #:export (chain chain-and chain-lambda chain-when nest nest-reverse)) + +(cond-expand-provide (current-module) '(srfi-197)) (define (gentemp) (car (generate-temporaries '(x)))) diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am index 1a1356d67..ecf4a3175 100644 --- a/test-suite/Makefile.am +++ b/test-suite/Makefile.am @@ -161,6 +161,7 @@ SCM_TESTS = tests/00-initial-env.test \ tests/srfi-111.test \ tests/srfi-119.test \ tests/srfi-171.test \ + tests/srfi-197.sr64 \ tests/srfi-4.test \ tests/srfi-9.test \ tests/statprof.test \ diff --git a/test-suite/tests/srfi-197.test b/test-suite/tests/srfi-197.sr64 similarity index 95% rename from test-suite/tests/srfi-197.test rename to test-suite/tests/srfi-197.sr64 index 35db27228..736aa7411 100644 --- a/test-suite/tests/srfi-197.test +++ b/test-suite/tests/srfi-197.sr64 @@ -1,3 +1,5 @@ +;;;; srfi-197.sr64 --- SRFI 197: Pipeline Operators test suite +;;;; ;;;; SPDX-FileCopyrightText: 2020 Adam R. Nelson ;;;; ;;;; SPDX-License-Identifier: MIT @@ -26,7 +28,16 @@ ;;;; CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE ;;;; SOFTWARE. -(include "./srfi-64-minimal.scm") +;;; Commentary: + +;;; The Copyright statement above was taken from the srfi-197.html file +;;; in the original source. + +;;; Code: + +(define-module (srfi-197-test) + #:use-module (srfi srfi-64) + #:use-module (srfi srfi-197)) (define (exclamation x) (string-append x "!")) @@ -236,3 +247,7 @@ (quote <>))) (test-end "Pipeline Operators") + +;; Local Variables: +;; mode: scheme +;; End: