Search code examples
lispschememit-scheme

Syntactic binding value must be a keyword: alpha. What does it mean?


Here is my little program:

(let-syntax ((alpha (lambda (x)
                      (list (syntax quote)
                            (list)))))
  (alpha))

And guile executes it, and returns (). But mit-scheme outputs the following:

;Syntactic binding value must be a keyword: alpha
;To continue, call RESTART with an option number:
; (RESTART 1) => Return to read-eval-print level 1.

Why?

(my version is: Release 9.1 || Microcode 15.3 || Runtime 15.7 || SF 4.41 || LIAR/i386 4.118 || Edwin 3.116)


Solution

  • MIT Scheme only provides syntax-rules, syntactic closures, and explicit renaming for defining syntax transformers. For the latter two, you want either sc-macro-transformer or the er-macro-transformer forms. If you want to use syntax objects, you'll need to use an implementation that supports syntax objects (which usually comes with syntax-case) such as Racket or Guile.

    By the way, even in a language with syntax objects your macro definition may not work because you're returning a list from your transformer instead of syntax. Also, the web page you linked to is a pretty old standard. You might want to read a more recent source on macros, such as TSPL4.