Paul F. Dietz <dietz@dls.net> wrote:
+---------------
| Kaz Kylheku wrote:
| > Tim Bradshaw <tfb@cley.com> wrote:
| >> (etypecase x
| >> (t "this is OK"))
| >>OK or not? I think it isn't, but I'm not sure.
| > Quick, sweep this under the rug before some comp.lang.schemer stumbles on it!
| It's ok. In fact, a test much like this is in the gcl ansi-tests.
| (Similar tests exist for CCASE, ECASE, and CTYPECASE.)
+---------------
Oops! CMUCL thinks otherwise (pun intended!):
> (etypecase 'foo
(t "this is OK"))
Error in function COMMON-LISP::CASE-BODY:
No default clause allowed in ETYPECASE: (T "this is OK")
...
Restarts:
0: [ABORT] Return to Top-Level.
0] vso 4
(DOLIST (CASE CASES)
(COND ((ATOM CASE) (ERROR "~S -- Bad clause in ~S." CASE NAME))
((MEMQ (CAR CASE) '(T OTHERWISE))
(IF ERRORP
(#:***HERE***
(ERROR "No default clause allowed in ~S: ~S" NAME CASE))
(PUSH `(,T ,NIL ,@(REST CASE)) CLAUSES)))
((AND MULTI-P (LISTP (FIRST CASE)))
(SETF KEYS (APPEND (FIRST CASE) KEYS))
(PUSH
`((OR
,@(MAPCAR #'(LAMBDA (KEY) `(,TEST ,KEYFORM-VALUE ',KEY))
(FIRST CASE)))
,NIL ,@(REST CASE))
CLAUSES))
(T (PUSH (FIRST CASE) KEYS)
(PUSH `((,TEST ,KEYFORM-VALUE ',(FIRST CASE)) ,NIL ,@(REST CASE))
CLAUSES))))
Hmmm... But if (listp (first case))... ;-} ;-}
> (etypecase 'foo
((or t) "this is OK"))
"this is OK"
>
-Rob
-----
Rob Warnock, PP-ASEL-IA <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607