[gambit-list] Getting let-syntax example from R5RS to work?

William william at soukoreff.com
Fri Jun 30 00:52:56 EDT 2023


Hi,

Sorry for asking yet another NOOB question, but I’m having trouble getting
“let-syntax” to work using the latest version of gambit.

I’m trying to use the let-syntax example code copied verbatim from page 14
of the R5RS standard:

~ ~ ~ ~
(let-syntax ((when (syntax-rules ()
                         ((when test stmt1 stmt2 ...)
                          (if test
                              (begin stmt1
                                     stmt2 ...))))))
   (let ((if #t))
      (when if (set! if ’now))
      if ))
~ ~ ~ ~

This is what happens when I cut and paste that code into “gsi”:

~ ~ ~ ~
% gsi -v
v4.9.3 20220102232246 x86_64-apple-darwin21.3.0 "./configure
'CC=gcc-mp-12' '--prefix=/Users/me/gambit' '--enable-single-host'
'--enable-march=native' '--enable-dynamic-clib'"
%
% gsi -:s
Gambit v4.9.3

> (let-syntax ((when (syntax-rules ()
                         ((when test stmt1 stmt2 ...)
                          (if test
                              (begin stmt1
                                     stmt2 ...))))))
   (let ((if #t))
      (when if (set! if ’now))
      if ))
*** ERROR IN (stdin)@2.14 -- Ill-formed special form
(when (syntax-rules () ((when test stmt1 stmt2 ...) (if test (begin stmt1
stmt2 ...)))))
> ,q
~ ~ ~ ~

I have tried specifying various command-line options to gsi, for example:

   gsi ~~lib/syntax-case -
   gsi
   gsi -:s
   gsi -:s,r5rs
   gsi -:s,r7rs

All of these produce essentially identical outputs.

Note that my version of gsi is the latest version.  I downloaded the file
“gambit-v4_9_4.tgz” from the gambit website, but when it is compiled the
executable reports that it is version 4.9.3.  This seems to be because the
file “gambit-4.9.4/include/stamp-release.h” contains the text “#define
___STAMP_RELEASE_VERSION "v4.9.3"”, but I assure you that I’ve downloaded
the 4.9.4 source file.

Anyway, and help would be greatly appreciated.

(Incidentally, the reason that I’m trying to get let-syntax working is
because I’d like to use Alex Shinn’s portable hygienic pattern matcher
“match.scm” with Gambit, but it uses let-syntax, which as you can see I
haven’t got to work.  Does anyone know whether there is a version of
match.scm already ported over to Gambit?)

Thanks,
- William







More information about the Gambit-list mailing list