Common Lisp the Language, 2nd Edition
The
syntax for etypecase and ctypecase is the same as for typecase, except
that no otherwise clause is permitted. Similarly, the syntax for ecase and
ccase is the same as for case except for the otherwise clause.
etypecase and ecase are similar to typecase and case, respectively, but signal a non-continuable error rather than returning nil if no clause is selected.
ctypecase and ccase are also similar to typecase and case, respectively, but signal a continuable error if no clause is selected.
[Macro]
etypecase keyform {(type {form}*)}*
[This supersedes the description of etypecase given in section 24.3.-GLS]
This control construct is similar to typecase, but no explicit otherwise or t clause is permitted. If no clause is satisfied, etypecase signals an error (of type type-error) with a message constructed from the clauses. It is not permissible to continue from this error. To supply an error message, the user should use typecase with an otherwise clause containing a call to error. The name of this function stands for ``exhaustive type case'' or ``error-checking type case.''
Example:
Lisp> (setq x 1/3) => 1/3 Lisp> (etypecase x (integer (* x 4)) (symbol (symbol-value x))) Error: The value of X, 1/3, is neither an integer nor a symbol. To continue, type :CONTINUE followed by an option number: 1: Return to Lisp Toplevel. Debug>
[Macro]
ctypecase keyplace {(type {form}*)}*
[This supersedes the description of ctypecase given in section 24.3.-GLS]
This control construct is similar to typecase, but no explicit otherwise or t clause is permitted.
The keyplace must be a generalized variable reference acceptable to setf. If no clause is satisfied, ctypecase signals an error (of type type-error) with a message constructed from the clauses. This error may be continued using the store-value restart. The argument to store-value is stored in keyplace and then ctypecase starts over, making the type tests again. Subforms of keyplace may be evaluated multiple times. If the store-value restart is invoked interactively, the user will be prompted for the value to be used.
The name of this function is mnemonic for ``continuable (exhaustive) type case.''
Example:
Lisp> (setq x 1/3) => 1/3 Lisp> (ctypecase x (integer (* x 4)) (symbol (symbol-value x))) Error: The value of X, 1/3, is neither an integer nor a symbol. To continue, type :CONTINUE followed by an option number: 1: Specify a value to use instead. 2: Return to Lisp Toplevel. Debug> :continue 1 Use value: 3.7 Error: The value of X, 3.7, is neither an integer nor a symbol. To continue, type :CONTINUE followed by an option number: 1: Specify a value to use instead. 2: Return to Lisp Toplevel. Debug> :continue 1 Use value: 12 => 48
[Macro]
ecase keyform {({({key}*) | key} {form}*)}*
[This supersedes the description of ecase given in section 24.3.-GLS]
This control construct is similar to case, but no explicit otherwise or t clause is permitted. If no clause is satisfied, ecase signals an error (of type type-error) with a message constructed from the clauses. It is not permissible to continue from this error. To supply an error message, the user should use case with an otherwise clause containing a call to error. The name of this function stands for ``exhaustive case'' or ``error-checking case.''
Example:
Lisp> (setq x 1/3) => 1/3 Lisp> (ecase x (alpha (foo)) (omega (bar)) ((zeta phi) (baz))) Error: The value of X, 1/3, is not ALPHA, OMEGA, ZETA, or PHI. To continue, type :CONTINUE followed by an option number: 1: Return to Lisp Toplevel. Debug>
[Macro]
ccase keyplace {({({key}*) | key} {form}*)}*
[This supersedes the description of ccase given in section 24.3.-GLS]
This control construct is similar to case, but no explicit otherwise or t clause is permitted.
The keyplace must be a generalized variable reference acceptable to setf. If no clause is satisfied, ccase signals an error (of type type-error) with a message constructed from the clauses. This error may be continued using the store-value restart. The argument to store-value is stored in keyplace and then ccase starts over, making the type tests again. Subforms of keyplace may be evaluated multiple times. If the store-value restart is invoked interactively, the user will be prompted for the value to be used.
The name of this function is mnemonic for ``continuable (exhaustive) case.''