[racket] syntax-parse and literals

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Fri Sep 2 22:38:40 EDT 2011

On Fri, Sep 2, 2011 at 10:10 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
> That fixed the problem, thanks.
>
> I was disappointed by some of the resulting error messages, though.
> I'm bringing these up here because I don't know whether these error
> messages are an artifact of the strategy Jay suggested.
>
> To simplify, suppose I have
>
> (define-syntax (defvar: stx)
>  (syntax-parse stx #:literals(:)
>   [(_ i:id : C:expr b:expr)
>    ...]))
>
> Here are some errors:
>
>  (defvar: y : 4)
>  -> defvar:: bad syntax in: (defvar: y : 4)
>
> Could have indicated a missing expression?
>
>  (defvar: y number? 4)
>  -> defvar:: expected the identifier `:' in: number?
>
> I have two nits with this:
>
> - : is meant to be a literal, not an identifier, and

I don't really understand this nit.  The : is a literal identifier.
It's like reading "expected the number 5" and saying, no, you should
expect the constant 5.  Well, yes.  It's a constant number, or a
numeric constant.  It's both.

--Carl



Posted on the users mailing list.