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: Elf
Subject: Re: [Chicken-users] Syntax of case expressions
Date: Sat, 1 Mar 2008 14:02:20 -0800 (PST)


no, actually, i get lots of errors about 'quote' being an invalid value to car in macros.

to demonstrate:

(define foo 'quote)
(case foo
    ('a 1)
    (else 2))  => 1

the proper behaviour in this case, btw, has not yet been given.

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

is the r5rs semantics of case.

will you believe me now when im telling you that chicken is not resolving the
symbols properly in macro forms?

-elf


On Thu, 28 Feb 2008, Ivan Raikov wrote:


 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?


_______________________________________________
Chicken-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/chicken-users





reply via email to

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