summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-10-14 21:48:19 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-10-14 21:48:19 -0700
commit552b03e28ce914ec3959ae7585525ef45b92fc44 (patch)
tree5515b9d9002db2fe6e7017ba6d1571803b7823fd /txr.1
parent9cef0547ba0ec81ce6051bb1cba9db5671e08e64 (diff)
downloadtxr-552b03e28ce914ec3959ae7585525ef45b92fc44.tar.gz
txr-552b03e28ce914ec3959ae7585525ef45b92fc44.tar.bz2
txr-552b03e28ce914ec3959ae7585525ef45b92fc44.zip
Adding typecase macro.
* lisplib.c (type_set_entries, type_instantiate): New static functions. (lisplib_init): Register new functions in dl_table. * share/txr/stdlib/type.tl: New file, providing typecase * txr.1: Documented typecase.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.143
1 files changed, 43 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 442a42fb..112719be 100644
--- a/txr.1
+++ b/txr.1
@@ -13173,6 +13173,49 @@ The following equivalence holds:
(typep a b) --> (subtypep (typeof a) b)
.cble
+.coNP Macro @ typecase
+.synb
+.mets (typecase < test-form >> {( type-sym << clause-form *)}*)
+.syne
+.desc
+The
+.code typecase
+macro evaluates
+.meta test-form
+and then successively tests its type against each clause.
+
+Each clause consists of a type symbol
+.meta type-sym
+and zero or more
+.metn clause-form -s.
+
+The first clause whose
+.meta type-sym
+is a supertype of the type of
+.metn test-form 's
+value is considered to be the matching clause.
+That clause's
+.metn clause-form -s
+are evaluated, and the value of the last form is returned.
+
+If there is no matching clause, or there are no clauses present,
+or the matching clause has no
+.metn clause-form -s,
+then
+.code nil
+is returned.
+
+Note: since
+.code t
+is the supertype of every type, a clause whose
+.meta type-sym
+is the symbol
+.code t
+always matches. If such a clause is placed as the last clause of a
+.codn typecase ,
+it provides a fallback case, whose forms are evaluated if none of the
+previous clauses match.
+
.coNP Function @ identity
.synb
.mets (identity << value )