![]() | ![]() | ![]() | case-using | ![]() |
|
| test keyform
{normal-clause}*
[otherwise-clause]
=> result*or nil | [Macro] |
Purpose
Conditionally execute the forms in a clause that is selected by
matching the result of evaluating keyform according to test.
Package :gbbopen-tools
Module :gbbopen-tools
Arguments and values
| test | A symbol designating a comparison predicate (not evaluated) | |
| keyform | A form; evaluated to produce a test-key (see below) | |
| results | The values returned by evaluating the last form in the
selected clause or nil
|
Returns
The values returned by the last form in the matching
normal-clause; otherwise the values returned by the last form in the
otherwise-clause, if specified; otherwise nil.
Detailed syntax
| normal-clause ::= | (keys form*) |
| otherwise-clause ::= | ({otherwise | t} form*) |
Terms
| test-key | An object produced by evaluating keyform | |
| keys | An object or a list of objects. To refer to the symbols t
and otherwise by themselves as the sole key object for a
normal-clause, (t) and (otherwise), respectively, must be
specified as the keys for the clause.
| |
| form | A form |
Description
The specified test symbol is not evaluated; however the comparison predicate that
it designates must be available during expansion of the case-using
form.
The keyform is first evaluated to produce the test-key.
Each of the normal-clauses is then considered in turn. If the test-key
matches that clause according to test, then the forms in that clause are evaluated
as an implicit progn, and the values it returns are returned as the value of
the case-using form.
Case-using is a generalization of Common Lisp's case macro.
See also
ccase-using
ecase-using
Examples
> (case-using string= "a"
("a" 1)
(("b" "c" "d") 2))
1
> (case-using string= "d"
("a" 1)
(("b" "c" "d") 2))
2
> (case-using string= "C"
("a" 1)
(("b" "c" "d") 2))
nil
> (case-using string= "C"
("a" 1)
(("b" "c" "d") 2)
(otherwise -1))
-1
> (case-using equalp "C"
("a" 1)
(("b" "c" "d") 2)
(otherwise -1))
2
>
The GBBopen Project
![]() | ![]() | ![]() | case-using | ![]() |