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

Re: 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.



>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)))


If you are allowed to add a line of "let" and then say that "=>" is not needed, 
with the same argument, I can say that "case" is not needed in our language at
all. Whenever you need a "case", I can always write it as one line of "let" 
and a "cond":

(define-syntax case
  (syntax-rules (else)
    ((case key
       ((atoms ...) result ...)
       ...)
     (let ((atom-key key))
       (cond ((memv atom-key '(atoms ...))
              result ...)
             ...)))
    ((case key
       ((atoms ...) result ...)
       ...
       (else else-result ...))
     (let ((atom-key key))
       (cond ((memv atom-key '(atoms ...))
              result ...)
             ...
             (else else-result ...))))))

BTW: This macro is in the first draft I send to srfi-editors. The editor asked me to 
remove it so you can find it in the current draft.

Sincerely,  
Chongkai Zhu