[gambit-list] R7RS Modules and Macros

Marc Feeley feeley at iro.umontreal.ca
Mon Feb 24 17:05:51 EST 2020


Indeed a recent commit seems to have broken macro definitions inside the define-library form.  I’ve now fixed the problem and also implemented define-macro in a define-library, so all the macro definitions in your example now work.

By the way, the implementation of define-library is still somewhat on the bleeding edge, so if you encounter what seems to be a bug you can import _define-library/debug to show the expansion of “import” and “define-library” forms to see if there’s an obvious mistake:

     % gsi . _define-library/debug x

where x is the module name.

Marc



> On Feb 22, 2020, at 2:34 PM, Tara Lorenz <tara at terralonza.de> wrote:
> 
> 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
> 
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://mailman.iro.umontreal.ca/cgi-bin/mailman/listinfo/gambit-list
> 





More information about the Gambit-list mailing list