R5RS syntax-rules macros in Gambit Scheme
The syntax-rules macro system is off by default in several Schemes. I tried as best I could to find out how to turn it on, but was not uniformly successful.
RScheme and Gambit produce an error
Well I remember it being a bit tricky to figure out how to do this in Gambit myself not too long ago, so I thought I’d share the method here and hopefully make it easier for others to find.
> (load "~~/syntax-case") "/usr/home/Martin/.snow-site/v1.1.2/host/gambit/v4.2.0/syntax-case.scm" > (define-syntax foo (syntax-rules () ((_) 1))) > (foo) 1 >
$ gsi -e '(load "~~/syntax-case")' - > (define-syntax foo (syntax-rules () ((_) 1))) > (foo) 1 >
I’m not fond of the ‘magic’ file path to get to it, but it comes with Gambit and it does work. If I recall correctly, it’s a port of psyntax.
2 Comments »