Re: (case 'quote ('lambda 1) (otherwise 2))
- From: "Greg Buchholz" <sleepingsquirrel@xxxxxxxxx>
- Date: 29 Jan 2007 14:26:36 -0800
David Wragg wrote:
I have found 2 Common Lisp implementations that think that the above
code evaluates to 1. This is quite surprising to me.
SBCL 1.0.2 (on Fedora Core 6 x86-64, from the extras repository)
* (case 'quote ('lambda 1) (otherwise 2))
[...]
1
CLisp 2.41 (as above):
[1]> (case 'quote ('lambda 1) (otherwise 2))
1
Both implementations give less surprising results for (eq 'quote
'lambda) and (case 'lambda ('quote 1) (otherwise 2)).
Is this the correct behavior (and if so, where should I look in the
Hyperspec to understand it)? Or do these independent implementations
share an obscure bug?
I think that the correct behavior, and should evaluate to 1 on all
Common Lisp systems. "case" doesn't evaluate its "key" arguments. So
'lambda is the same as the two element list (quote lambda). Compare
to...
(case 'quote
((lambda quote) 1)
(otherwise 2))
....which also evaluates to 1. You might also want to study these
examples...
(case 'foo
((foo bar baz) 1)
(otherwise 2))
(case 'bar
((foo bar baz) 1)
(otherwise 2))
.
- Follow-Ups:
- Re: (case 'quote ('lambda 1) (otherwise 2))
- From: David Wragg
- Re: (case 'quote ('lambda 1) (otherwise 2))
- References:
- (case 'quote ('lambda 1) (otherwise 2))
- From: David Wragg
- (case 'quote ('lambda 1) (otherwise 2))
- Prev by Date: Re: Integer to Character conversion
- Next by Date: Re: (case 'quote ('lambda 1) (otherwise 2))
- Previous by thread: (case 'quote ('lambda 1) (otherwise 2))
- Next by thread: Re: (case 'quote ('lambda 1) (otherwise 2))
- Index(es):
Relevant Pages
|