[plt-scheme] A question about external representation

From: Chongkai Zhu (czhu at cs.utah.edu)
Date: Sat Jan 26 17:24:22 EST 2008

v399 doc is more clear:

(case val-expr case-clause ...)

case-clause
= [(datum ...) then-expr ...+]
| [else then-expr ...+]

Evaluates val-expr and uses the result to select a case-clause. The 
selected clause is the first one with a datum whose quoted form is eqv? 
to the result of val-expr. If no such datum is present, the else 
case-clause is selected; if no else case-clause is present, either, then 
the result of the case form is #<void>.

So your program doesn't work with "case" because:

 > (eqv? ''t ''t)
#f

In this case, I would use pattern-match:

(define test2
(match-lambda
('test2 "quote test2")
(''test2 "quote quote test2")
(_ #f)))

(test2 'test2)
(test2 ''test2)

Chongkai


Grant Rettke wrote:
> Today I worked on a problem that involved converting a 'cond'
> expression to 'case.
>
> I was checking for 'value in the cond expression, but in the case I
> should have been checking for unquoted value.
>
> For example:
>
> (define test2
>   (? (arg)
>     (case arg
>       ([test2] "quote test2")
>       (['test2] "quote quote test2")
>       (else #f))))
>
>   
>> (test2 'test2)
>> (test2 ''test2)
>>     
>
> Reading the documentation for case it says that each datum checked for
> equality is "an external representation" of some object.
>
> My question is, when we type (quote value), is the external
> representation whatever shows up in the repl when that is evaluated?
>
> What is external representation?
>   
> ------------------------------------------------------------------------
>
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>   



Posted on the users mailing list.