5.6. Macro `EXT:FCASE`
Prev | Chapter 5. Data and Control Flow | Next

## 5.6. Macro `EXT:FCASE`

This macro allows specifying the test for `CASE`, e.g.,

    (fcase string= (subseq foo 0 (position #\Space foo))
      ("first" 1)
      (("second" "two") 2)
      (("true" "yes") t)
      (otherwise nil))

is the same as

    (let ((var (subseq foo 0 (position #\Space foo))))
      (cond ((string= var "first") 1)
            ((or (string= var "second") (string= var "two")) 2)
            ((or (string= var "true") (string= var "yes")) t)
            (t nil)))

If you use a built-in `HASH-TABLE` test (see Section 18.3, “Function `HASH-TABLE-TEST`”) as the test (e.g., `EQUAL` instead of `STRING=` above, but not a test defined using `EXT:DEFINE-HASH-TABLE-TEST`), the compiler will be able to optimize the `EXT:FCASE` form better than the corresponding `COND` form.

| These notes document CLISP version 2.45 | Last modified: 2008-05-14

Enter your search termsSubmit search form
Webclisp.cons.orgclisp.podval.orgwww.lisp.org

Prev | Up | Next
5.5. Macro `DEFCONSTANT` | Home | 5.7. Function EXT:XOR