(hello

‘world)

R5RS syntax-rules macros in Gambit Scheme

Stumbled upon Alexey Radul‘s list of Scheme Implementation Choices, and noticed that Gambit was listed as no-syntax-rules:

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
>

or

$ 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.

June 29, 2008 - Posted by | Programming, Scheme

2 Comments »

  1. Correction (since this is the first hit for [gambit-c syntax-rules] on Google):

    (load “~~/lib/syntax-case”)

    Comment by John Cowan | February 27, 2010 | Reply

    • Things change in a couple years😉

      Comment by prael | February 27, 2010 | Reply


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: