[gambit-list] R7RS Modules and Macros

Tara Lorenz tara at terralonza.de
Sat Feb 22 14:34:50 EST 2020


Hello,
i was under the impression that at least syntax-rules macro would
work the new r7rs module-system.  However, with this file

$ cat x.sld
(define-library (x)
  (import (gambit))
  (export a b c d)
  (begin
    (define (a)
      "usual variable")
    (define-macro (b)
      "plain old defmacro")
    (define-syntax c
      (syntax-rules ()
        ((_)
         "via syntax-rules")))
    (define-syntax d
      (lambda (stx)
        (syntax-case stx ()
          ((_)
           #'"per syntax-case"))))))

this is what i get, as expected:

$ gsi .
Gambit v4.9.3

> (include "x.sld")
> (import (x))
> (a)
"usual variable"
> (b)
"plain old defmacro"
> (c)
"via syntax-rules"
> (d)
"per syntax-case"
> (exit 0)

Howerver without the include, things look not so well:

$ gsi .
Gambit v4.9.3

> (import (x))
> (a)
"usual variable"
> (b)
*** ERROR IN (stdin)@3.2 -- Unbound variable: x#b
1> ,t
> (c)
*** ERROR IN (stdin)@5.2 -- Unbound variable: x#c
1> ,t
> (d)
*** ERROR IN (stdin)@7.2 -- Unbound variable: x#d
1>

When doing the same exercise using the lolevel module system, as
in:

$ cat lolevel\#.scm
cat lolevel\#.scm
(##namespace ("lolevel#" a b c d))
(##import gambit)
(define-macro (b)
  "plain old defmacro")
(define-syntax c
  (syntax-rules ()
    ((_)
     "via syntax-rules")))
(define-syntax d
  (lambda (stx)
    (syntax-case stx ()
      ((_)
       #'"per syntax-case"))))
$ cat lolevel.scm
(##supply-module lolevel)
(define (a)
      "usual variable")

a simple '(include (lolevel))' suffices, no need for explicitly
including anything. So, am i missing something or are my expectations
wrong? I should add, that i experience the same problem with the
udem-dltem srfi/26 code.  So maybe something is just wrong on my side.

Cheers, Tara




More information about the Gambit-list mailing list