chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Syntax of case expressions


From: Ivan Raikov
Subject: Re: [Chicken-users] Syntax of case expressions
Date: Thu, 28 Feb 2008 11:47:27 +0900
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

  Remember that in Scheme, (define foo 'a) is a shortcut for 
(define (define foo (quote a))) -- quote is a special form, and not
a part of the literal. So you in your case statement you are not
matching the symbol a, you are actually matching the symbol 'a (the
apostrophe is treated as a literal in the case statement). Your first
example should actually be: 

(case foo
  ((a) 1)
  (else 2))

Chicken works as expected with that code. 

  -Ivan

Matt Gushee <address@hidden> writes:

> Hi, all--
>
> I have just written a 'string-case' macro--it is supposed to behave
> just like case, except that it uses string=? in place of eqv? as its
> equality predicate. But in the course of writing test cases, I have
> encountered a surprise: the Chicken version of case appears to be
> non-compliant with R5RS.
>
> The spec says
>
>   Syntax: <Key> may be any expression. Each <clause> should have the
>     form
>
>   ((<datum1> ...) <expression1> <expression2> ...),
>
> But the syntax implemented in Chicken appears to be
>
>   (<datum> <expression1> <expression2> ...)
>
> E.g.:
>
> csi> (define foo 'a)
> csi> (case foo
> --->    (('a) 1)
> --->    (else 2))
> 2
> csi> (case foo
> --->   ('a 1)
> --->   (else 2))
> 1
>
> Or have I misunderstood something?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]