[gambit-list] Ill formed expression

Marc Feeley feeley at iro.umontreal.ca
Thu Nov 10 10:27:46 EST 2011

On 2011-11-10, at 6:42 AM, Per Eckerdal wrote:

> syntax-case does all kinds of things, not just to add syntax-case support. It is essentially a Scheme-to-Scheme compiler in itself. I don't remember exactly what it changes, but I think for one that it doesn't fully support Gambit's DSSSL parameter lists.

Indeed.  You can view the syntax-case implementation as offering a new language layer which hides (most of) the syntactic layer offered by Gambit.  So when you load syntax-case you get hygienic macros, but you lose things too, in particular the source code is rewritten and the decompilation of code deviates from what the user wrote (variables are renamed, for example, which is a pain when debugging).  The comments at the top of lib/syntax-case.scm, copied below, give some details.

Another reason syntax-case is not "built-in" to Gambit is that syntax-case.scm is *HUGE*.  Once compiled, it is comparable to the size of the interpreter itself (which contains the whole runtime system and library functions):

% ls -lh lib/syntax-case.o1 gsi/gsi
-rwxr-xr-x  1 feeley  feeley   3.9M Oct 22 14:56 gsi/gsi
-rwxr-xr-x  1 feeley  feeley   3.0M Nov 10 10:13 lib/syntax-case.o1

This bloat is unacceptable.

I would like Gambit to have an integrated compact implementation of hygienic macros.  I am considering implementing this with all the other R7RS changes, if the new spec is acceptable.


;; This file can be used to replace the builtin macro expander of the
;; interpreter and compiler.  Source code correlation information
;; (filename and position in file) is preserved by the expander.  The
;; expander mangles non-global variable names and this complicates
;; debugging somewhat.  Note that Gambit's normal parser processes the
;; input after expansion by the syntax-case expander.  Since the
;; syntax-case expander does not know about Gambit's syntactic
;; extensions (like DSSSL parameters) some of the syntactic
;; extensions cannot be used.  On the other hand, the syntax-case
;; expander defines some new special forms, such as "module",
;; "alias", and "eval-when".

;; You can simply load this file at the REPL with:
;;   (load "syntax-case")
;; For faster macro processing it is worthwhile to compile the file
;; with the compiler.  You can also rename this file to "gambcext.scm"
;; and put it in the Gambit "lib" installation directory so that it is
;; loaded every time the interpreter and compiler are started.
;; Alternatively, the expander can be loaded from the command line
;; like this:
;;   % gsi ~~lib/syntax-case -
;;   > (pp (lambda (x y) (if (< x y) (let ((z (* x x))) z))))
;;   (lambda (%%x0 %%y1)
;;     (if (< %%x0 %%y1) ((lambda (%%z2) %%z2) (* %%x0 %%x0)) (void)))

More information about the Gambit-list mailing list