Email list hosting service & mailing list manager


I see little need Ben Goetter 10 Apr 2006 22:26 UTC

 > (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.