Re: historical rationale?
Taylor R. Campbell 10 Apr 2006 22:27 UTC
Date: Mon, 10 Apr 2006 16:58:03 -0400
From: Neil Van Dyke <xxxxxx@neilvandyke.org>
This seems like a useful feature, and I recall wondering myself why
RnRS "cond" had "=>" yet "case" did not.
I suspect the distinction involved reduced-sugar diet: getting the value
of a clause test within "cond" is very hard without "=>", but getting
the key of a "case" form without "=>" is easy.
Well, both transformations are fairly easy. However, one might argue
that the grossness in the COND expansion far outweighs that in the
CASE expansion, justifying COND's => but not CASE's. It's a very
common idiom in older Lisps without => in COND clauses, but I
generally don't even think twice about writing a CASE with a LET
around it; it would probably be more mental effort to start using this
SRFI.
(CASE key
...
((datum ...) => receiver)
...)
<=>
(LET ((K key))
(CASE K
...
((datum ...) (receiver K))
...))
(COND ...
(test => receiver)
...)
<=>
(LET ((TEMP #F))
(COND ...
((BEGIN (SET! TEMP test) TEMP)
(receiver TEMP))
...))
Also, "cond"'s "=>" is a somewhat unfortunate kind of sugar, as some
syntax transformers that can produce "cond" forms have to specially
handle "=>" identifiers in their input syntax. Adding "=>" sugar to
"case" would similarly burden some syntax extensions that produce "case"
forms.
Hmmm. I'm confused. Can you elaborate on this?
I looked, by the way, into some old mail archives, dating back to
1983, and couldn't find any discussion of the rationale for =>. It
was in T before it entered RnRS, and as far back as I can find it has
always been there in T. My guess as to why it never entered CASE
would be simply that it never crossed anyone's mind, although probably
only Jonathan Rees and Kent Pitman could say for sure.