Aaron VanDevender <[EMAIL PROTECTED]> writes:

> Hello,
>
> I have noticed that guile evaluates the following to #t
>
> (case 'x
>   ('x #t)
>   (else #f))
>
> even though R5RS section 4.2.1 seems to say that all of the statements
> (besides else) must be of the form ((datum ...) ...). Clearly the symbol
> 'x is not a list. What is going on here?

It is a bit tricky.  The syntax 'x is short for (quote x).  This
expansion is done by the reader without looking at the context.  So,
what the evaluator really sees is

  (case 'x
    ((quote x) #t)
    (else #f))

This is indeed in the form required by R5RS, although probably only by
accident.  As expected, the following also evaluates to true:

  (case 'quote
    ('x #t)
    (else #f))
  => #t

Also (and don't try this at home kids):

  (define 'x (* x x))
  '2
  => 4

-- 
GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user

Reply via email to