guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to convert r7rs module using include-library-declarations to Guile?


From: Felix Thibault
Subject: How to convert r7rs module using include-library-declarations to Guile?
Date: Sun, 27 Sep 2020 15:07:10 -0400

I am working on a pattern-matcher that exports all of its auxiliary
syntax ($ *** =.. *.. get! etc., a modified version of Alex Shinn's
syntax).

It works in Guile, and I'm trying to refactor it to use srfi-206, but
if I try to import (only (srfi srfi-206 all) $ *** =.. etc) with just
the names changed in guile-3 I get:

source expression failed to match any pattern in form (())

If I simplify (srfi srfi-206 all) to:

(define-library (srfi srfi-206 all)
  (include-library-declarations "all-exports.scm")
  (import (guile))
  (begin
    (define-syntax define-identifier-syntax-parameter
      (syntax-rules ()
       ((_ name e)
       (define-syntax name
         (syntax-rules ()
         ((_ . _) e))))))
    (define-syntax define-auxiliary-syntax
      (syntax-rules ()
        ((_ name)
(define-identifier-syntax-parameter name
    (syntax-error "invalid use of auxiliary syntax" name))))))
(include "all-definitions.scm"))

I get:

definition in expression context ... for form
 ((define-syntax define-identifier-syntx-parameter ...))

So I tried putting that module in Guile form:

(define-module (srfi srfi-206 all))
  (include-from-path "srfi/srfi-206/all-exports.scm")
  (import (guile))
    (define-syntax define-identifier-syntax-parameter
      (syntax-rules ()
       ((_ name e)
                (define-syntax name
               (syntax-rules ()
                ((_ . _) e))))))
    (define-syntax define-auxiliary-syntax
      (syntax-rules ()
               ((_ name)
         (define-identifier-syntax-parameter name
          (syntax-error "invalid use of auxiliary syntax" name)))))
(include-from-path "srfi/srfi-206/all-definitions.scm")

and it loaded, but it didn't work: all the tests on the module that
fail when the pattern-matcher doesn't recognize the renamed auxiliary
syntax failed. Like

(match '(1 2 2 2) ((a (? number? b) ...) b)) ERROR

(match '(1 (2 2 2)) ((a (? number? b) ...) b)) => (2)

Is there a way to convert this module to Guile-2 and Guile-3 as it is now?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]