From 552b03e28ce914ec3959ae7585525ef45b92fc44 Mon Sep 17 00:00:00 2001
From: Kaz Kylheku <kaz@kylheku.com>
Date: Wed, 14 Oct 2015 21:48:19 -0700
Subject: 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.
---
 txr.1 | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

(limited to 'txr.1')

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 )
-- 
cgit v1.2.3