[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

I see little need

This page is part of the web mail archives of SRFI 87 from before July 7th, 2015. The new archives for SRFI 87 contain all messages, not just those from before July 7th, 2015.

> (case (get-symbol)
>  ((true) #t)
>  ((false) #f)
>  (else => (lambda (x) x)))
>Without the => clause in case, we have to write:
>(let ((key (get-symbol)))
>  (cond ((eq? key 'true) #t)
>        ((eq? key 'false) #f)
>        (else key)))

Am I missing something subtle?  Per this example, we only have to write

(let ((x (get-symbol)))
(case x
 ((true) #t)
 ((false) #f)
 (else x)))

The only difference between this and its => equivalent is the scope of 'x'.

In cond, the => helps capture a useful value on the left-hand side of a cond clause that is otherwise not easily captured. It seems much less useful in a case, since the left-hand side of a case clause always consists of literal eqv-testable constants, and the capture trivial.

The main argument for this would seem to me to be symmetry with cond.