On Sun, 15 Jul 2018 20:36:41 +0200 Martin Schneeweis <mar...@schneeweis.at> 
wrote:

> [...]
> please can someone explain to me why the following even works?
> 
>   (define sym 'b)
> 
>   (case sym
>     ('a "an 'a'")
>     ('b "a 'b'")
>     ('c "a 'c'")
>     (else "something else")) ; -> a 'b'
> [...]
> I know the r5rs document just says "Each <clause> _should_ have the
> form ((<datum1> ...) <expression1> <expression2> ...)
> [...]

Hello,

contrary to what you assume, these clauses *are* actually in the form specified 
by the standard :-D

The apostrophe is a *reader* macro, so before the compiler or interpreter ever 
gets to see that code, 'a is transformed to (quote a), 'b to (quote b) and 'c 
to (quote c). These three forms are obviously lists with two elements and 
represent case descriptors matching the symbols quote or a, quote or b and 
quote or c respectively.

Try setting sym to 'quote and see what happens!

Ciao,
Thomas


-- 
The greatest victory is that which requires no battle.
-- Sun Tzu, "The Art of War"

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

Reply via email to