dotted-lengthGBBopen Toolsensure-finalized-classecase-usingGoTo Top

ecase-using   test keyform {clause}* => result*[Macro]

Purpose
Conditionally execute the forms in a clause that is selected by matching the result of evaluating keyform according to test, generating an error if no clause is selected.

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

Returns
The values returned by the last form in the selected clause.

Errors
No clause was selected.

Detailed syntax

clause ::= (keys form*)

Terms

test-key     An object produced by evaluating keyform
keys     An object or a proper list of objects.
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 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 ecase-using form.

If no clause is selected, a non-correctable error of type case-using-failure (a subclass of type-error) is signaled. The offending datum is the test-key and the expected type is type equivalent to (member (union keys :test test).

Ecase-using is a generalization of Common Lisp's ecase macro.

See also
    case-using-failure
    case-using
    ccase-using

Examples

  > (ecase-using string= "a"
      ("a" 1)
      (("b" "c" "d") 2))
  1
  > (ecase-using string= "d"
      ("a" 1)
      (("b" "c" "d") 2))
  2
  > (ecase-using string= "C"
      ("a" 1)
      (("b" "c" "d") 2))
  Error: "C" fell through an ecase-using string= form; 
         the valid keys are "a", "b", "c", and "d".
  >>


The GBBopen Project


dotted-lengthGBBopen Toolsensure-finalized-classecase-usingGoTo Top