[racket] syntax-parse and literals

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Sep 2 23:14:02 EDT 2011

20 minutes ago, Shriram Krishnamurthi wrote:
> I guess to me, the term "literal identifier" is an oxymoron.  It's
> either a literal (5, #f, in this case :) or an identifier (foo, car,
> +).  Unless "identifier" means nothing more or less than "symbol".

-1 for both...

> When I write (:) in syntax-case, I'm saying ": is not a binding
> form; I want to see literally a :, and I don't want to bind the : in
> the pattern to whatever you find in that position".  I'm trying to
> reproduce that effect here.

But the nice property of using a syntax parameter comes with
abandoning the literal-ness of the particular name that you chose.  I
can always require your library and reprovide it by a different name.

So while "identifier" is technically correct, I completely agree that
it's very confusing.  I can't see anyone who would see that error
message and not wonder about it.  So I think that it does deserve a
better label -- and I think that "keyword" would work:

  (defvar: y number? 4)
  defvar:: expected the keyword `:' [...]

"Keyword" does have some historical baggage, but I don't think it's a
problem in this case.  What might be a problem is getting confused
with the #:foo keywords.

Another alternative is to just drop it:

  (defvar: y number? 4)
  defvar:: expected `:' [...]

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.