On Nov 15, 2008, at 12:38 PM, William Cook wrote:
Why doesn't the Gambit define-macro (and syntax-case) just do the right thing?
The R6RS syntax-case system that was developed for Ikarus (ported to some 12 other Scheme implementations including Gambit) does precisely that. At every macro transcription step, the source of the macro input (the form itself) is applied to the list of annotations of the output form, and duplicates are cancelled (in the same manner how marks cancel, but that's irrelevant). This gives allows syntax errors to show the macro expansion steps that resulted in the syntax error (when available); instead of just showing the final error.
Here's an example:
$ cat q.ss (import (rnrs))
(define-syntax let^ (syntax-rules () [(_ ([x* v*] ...) e e* ...) ((lambda (x* ...) e e* ...) v* ...)]))
(define-syntax L (syntax-rules () [(_ x v e) (let^ ([x v]) e)]))
(L v 13 (L 12 x (+ v x)))
$ ikarus --r6rs-script q.ss Unhandled exception: Condition components: 1. &who: lambda 2. &message: "not an identifier" 3. &syntax: form: (lambda (12) (+ v x)) subform: 12 4. &trace: #<syntax (lambda (12) (+ v x))> 5. &trace: #<syntax (let^ ((12 x)) (+ v x))> 6. &trace: #<syntax (L 12 x (+ v x)) [char 214 of q.ss]>
Aziz,,,