This is the matrix-case Reference Manual, version 0.1.4, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 06:59:08 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
matrix-case
Control flow macros which writing nested CASE easily.
SATO Shinichi
(GIT git@github.com:hyotang666/matrix-case)
Public domain
0.1.4
matrix-case.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
matrix-case/matrix-case.lisp
matrix-case
(system).
matrix-case
(macro).
matrix-ccase
(macro).
matrix-ctypecase
(macro).
matrix-ecase
(macro).
matrix-etypecase
(macro).
matrix-typecase
(macro).
canonicalize
(function).
defmatrix
(macro).
fix-underlying
(function).
integrate-candidates
(function).
matrix
(function).
Packages are listed by definition order.
matrix-case
common-lisp
.
matrix-case
(macro).
matrix-ccase
(macro).
matrix-ctypecase
(macro).
matrix-ecase
(macro).
matrix-etypecase
(macro).
matrix-typecase
(macro).
canonicalize
(function).
defmatrix
(macro).
fix-underlying
(function).
integrate-candidates
(function).
matrix
(function).
Definitions are sorted by export status, category, package, and then by lexicographic order.
# MATRIX-CASE, MATRIX-ECASE, MATRIX-CCASE
## [Macro] MATRIX-CASE MATRIX-ECASE MATRIX-CCASE
# Description: Like CL:CASE, but represents nested case.
“‘lisp
#?(op (0 1 2)
((0 0 0) :no)
((0 1 1) :no)
((0 1 2) :yes)
(otherwise :never))
=> :YES
“‘
“‘lisp
#?(matrix-case (0 1)
(((0 2 4 6 8) (1 3 5 7 9)) :yes)
(((0 2 4 6 8) (0 2 4 6 8)) :no)
(((1 3 5 7 9) (0 2 4 6 8)) :no))
=> :YES
“‘
### syntax
(MATRIX-CASE (&rest keyform) &body clause\*)
=> result
### Arguments and Values:
# keyform := a form; evaluated to produce a test-key.
# clause := ((test-key*) body)
test-key := an object produced by evaluating keyform.
body := an implicit PROGN.
# result := the values returned by the body in the matching clause.
# Affected By: none
# Side-Effects: none
# Notes:
# Exceptional-Situations:
# MATRIX-CASE, MATRIX-ECASE, MATRIX-CCASE
## [Macro] MATRIX-CASE MATRIX-ECASE MATRIX-CCASE
# Description: Like CL:CASE, but represents nested case.
“‘lisp
#?(op (0 1 2)
((0 0 0) :no)
((0 1 1) :no)
((0 1 2) :yes)
(otherwise :never))
=> :YES
“‘
“‘lisp
#?(matrix-case (0 1)
(((0 2 4 6 8) (1 3 5 7 9)) :yes)
(((0 2 4 6 8) (0 2 4 6 8)) :no)
(((1 3 5 7 9) (0 2 4 6 8)) :no))
=> :YES
“‘
### syntax
(MATRIX-CASE (&rest keyform) &body clause\*)
=> result
### Arguments and Values:
# keyform := a form; evaluated to produce a test-key.
# clause := ((test-key*) body)
test-key := an object produced by evaluating keyform.
body := an implicit PROGN.
# result := the values returned by the body in the matching clause.
# Affected By: none
# Side-Effects: none
# Notes:
# Exceptional-Situations:
# MATRIX-ETYPECASE, MATRIX-CTYPECASE
#### When any clause satisfies, an ERROR is signaled.
“‘lisp
#?(op (0)
((symbol) :never))
:signals ERROR
“‘
# MATRIX-CASE, MATRIX-ECASE, MATRIX-CCASE
## [Macro] MATRIX-CASE MATRIX-ECASE MATRIX-CCASE
# Description: Like CL:CASE, but represents nested case.
“‘lisp
#?(op (0 1 2)
((0 0 0) :no)
((0 1 1) :no)
((0 1 2) :yes)
(otherwise :never))
=> :YES
“‘
“‘lisp
#?(matrix-case (0 1)
(((0 2 4 6 8) (1 3 5 7 9)) :yes)
(((0 2 4 6 8) (0 2 4 6 8)) :no)
(((1 3 5 7 9) (0 2 4 6 8)) :no))
=> :YES
“‘
### syntax
(MATRIX-CASE (&rest keyform) &body clause\*)
=> result
### Arguments and Values:
# keyform := a form; evaluated to produce a test-key.
# clause := ((test-key*) body)
test-key := an object produced by evaluating keyform.
body := an implicit PROGN.
# result := the values returned by the body in the matching clause.
# Affected By: none
# Side-Effects: none
# Notes:
# Exceptional-Situations:
# MATRIX-ETYPECASE, MATRIX-CTYPECASE
#### When any clause satisfies, an ERROR is signaled.
“‘lisp
#?(op (0)
((symbol) :never))
:signals ERROR
“‘
# MATRIX-TYPECASE, MATRIX-ETYPECASE, MATRIX-CTYPECASE
## [Macro] MATRIX-TYPECASE MATRIX-ETYPECASE MATRIX-CTYPECASE
# Description: Like CL:TYPECASE, but represents nested typecases.
“‘lisp
#?(let((a 0))
(op(a ’key)
((symbol integer):never)
((integer symbol):yes!)
(otherwise :no!)))
=> :YES!
“‘
#### Only one cluase’s body will be evaluated.
“‘lisp
#?(op (0 ’sym 1)
((symbol symbol symbol) (princ :sss))
((symbol symbol integer) (princ :ssi))
((symbol integer symbol) (princ :sis))
((symbol integer integer) (princ :sii))
((integer symbol integer) (princ :yes))
((integer symbol symbol) (princ :iss))
((integer integer integer) (princ :iii))
((integer integer symbol) (princ :iis))
(otherwise (princ :otherwise)))
:outputs "YES"
“‘
#### Of course, we can use compound type specifier.
“‘lisp
#?(op (0)
(((and integer (eql 1))) :no)
(((member 0 2 4 6 8)) :yes))
=> :YES
“‘
#### T as wildcard
“‘lisp
#?(op ("hoge" 0)
((t symbol) :no)
((t fixnum) :yes)
((string string) :no))
=> :yes
“‘
#### NOTE! wildcard is treated as last resort.
“‘lisp
#?(op ("1" "2")
((t string) :no)
((string string) :yes))
=> :yes
“‘
“‘lisp
#?(op ("1" "2")
((string t) :no)
((string string) :yes))
=> :yes
“‘
#### NOTE! Each clause is tested left to right order.
“‘lisp
#?(op (:a :b)
((null null) :no)
((atom atom) :yes))
=> :yes
“‘
### syntax
(MATRIX-TYPECASE targets &body clauses)
=> result
### Arguments and Values:
# targets := (target*)
target := one lisp form
#### every TARGET forms are evaluated only once.
“‘lisp
#?(op ((princ 0) (princ 1))
((symbol symbol) :no)
((integer symbol) :no)
((symbol integer) :no)
(otherwise :no))
:outputs "01"
“‘
# clauses := ((typespecifier+) &body body)
typespecifier := see hyperspec
body := implicit PROGN
# result := T
# Affected By: none
# Side-Effects: none
# Notes:
#### Empty TARGETS is valid but, in such case CLAUSES must empty.
#### Such form evaluated to be NIL by macro expansion.
“‘lisp
#?(op () ())
=> NIL
“‘
“‘lisp
#?(op () ())
:expanded-to NIL
“‘
“‘lisp
#?(op ())
=> NIL
“‘
“‘lisp
#?(op ())
:expanded-to NIL
“‘
“‘lisp
#?(op)
:signals ERROR
“‘
#### ECL/16.1.3 specific issue.
.
“‘lisp
#?(flet ((doit ()
(op (’(elt))
((atom) :atom)
(otherwise :other))))
(doit))
=> :other
“‘
# Exceptional-Situations:
#### when TARGETS length and each TYPE-SPECIFIERS length is different,
#### an error is signaled.
“‘lisp
#?(op (0)
((symbol integer) :error))
:signals ERROR
“‘
“‘lisp
#?(op (0 :hoge)
((integer) :error))
:signals ERROR
“‘
#### others
# MATRIX-TYPECASE
#### Default return value is NIL.
“‘lisp
#?(matrix-typecase (0)
((symbol) :no))
=> NIL
“‘
#### Expanded examples.
“‘lisp
#?(matrix-typecase (0)
((integer) :yes)
(otherwise :no))
:expanded-to (let ((var 0))
(typecase var
(integer :yes)
(otherwise :no)))
“‘
“‘lisp
#?(matrix-typecase (0 ’sym)
((symbol integer) :no)
((integer symbol) :yes)
(otherwise :never))
:expanded-to (let ((var1 0))
(typecase var1
(symbol (let ((var2 ’sym))
(typecase var2
(integer :no)
(otherwise :never))))
(integer (let ((var3 ’sym))
(typecase var3
(symbol :yes)
(otherwise :never))))
(otherwise :never)))
“‘
Move T clause to the last as otherwise clause.
Remove prefix "E" or "C", if otherwise clause exists.
Jump to: | C D F I M |
---|
Jump to: | C D F I M |
---|
Jump to: | F M P S |
---|
Jump to: | F M P S |
---|