I recently ran into a problem that took me hours to diagnose.
It turns out that a `#:with` clause in a syntax-parse was not matching, but I 
would never have guessed
that from the error message I got.

Here is a simplified example:

  (define-syntax-rule (my-fancy-macro syn ...) (begin syn ...))

  (define-syntax (my-let syn)
    (syntax-parse syn
      #:literals (begin)
      [(_ ([x e] ...) body)
       #:with (lambda (y ...) (begin e^ ...))
       (local-expand #`(lambda (x ...) (my-fancy-macro e ...)) 'expression null)
       #`((lambda (y ...) body) e^ ...)]))

  (my-let ([x 5]) x)
  ; /tmp/test.rkt:29.0: my-let: expected the identifier `begin'
  ;   at: quote
  ;   in: (my-let ((x 5)) x)
  ; Context: ....

It's not clear where "quote" comes from; it doesn't appear in the syntax I've 
written
down or any of the patterns I've written, so it's totally useless for debugging.

It gets even worse when I remember I forgot to declare `lambda' as a literal:

  (define-syntax (my-let syn)
    (syntax-parse syn
      #:literals (lambda begin)
      [(_ ([x e] ...) body)
       #:with (lambda (y ...) (begin e^ ...))
       (local-expand #`(lambda (x ...) (my-fancy-macro e ...)) 'expression null)
       #`((lambda (y ...) body) e^ ...)]))

  (my-let ([x 5]) x)
  ; /tmp/test.rkt:29.0: my-let: expected the identifier `lambda
  ;   at: lambda
  ;   in: (my-let ((x 5)) x)
  ; Context: ....

So, we expected to see identifier that is there?
That's a strange error.
I'm not sure if this one is related, but it came up in the same debugging 
session.

Is there anything to be done about these error message?

-- 
William J. Bowman
Northeastern University
College of Computer and Information Science

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: signature.asc
Description: PGP signature

Reply via email to