[racket] `'unquote -- error or not?

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Jul 7 10:12:45 EDT 2011

7 minutes ago, Bas Steunebrink wrote:
> Ciao a tutti,
> 
> When I type `'unquote in DrRacket, an error is thrown:
> 
>  > `'unquote
> (X) unquote: expects exactly one expression in: (unquote)
> 
> I understand why this error occurs from the way quasiquote is
> expanded; see
> e.g. http://community.schemewiki.org/?scheme-faq-language#qqmacro (I
> guess DrRacket works similarly). Still, I feel the result should be
> just 'unquote. What do you think?

I like the error.

We have

  (quasiquote (quote foo))      evaluates to the list  (quote foo)
  (quasiquote (quote (foo)))    evaluates to the list  (quote (foo))
  (quasiquote (quote (foo 1)))  evaluates to the list  (quote (foo 1))
  (quasiquote (quote bar))      evaluates to the list  (quote bar)
  (quasiquote (quote (bar)))    evaluates to the list  (quote (bar))
  (quasiquote (quote (bar 1)))  evaluates to the list  (quote (bar 1))

You want to extend it in a way that is assymmetric to the above,

1 (quasiquote (quote unquote))      evaluates to the list  (quote unquote)
2 (quasiquote (quote (unquote)))    evaluates to the list  (quote (unquote))?
3 (quasiquote (quote (unquote 1)))  evaluates to the list  (quote 1)

#1 is what you want
#2 is possibly something you'd want too
#3 is what it should do

Given that it should do #3, I prefer #1 to be a syntax error.

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


Posted on the users mailing list.