summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2015-09-08 07:01:42 -0700
committerKaz Kylheku <kaz@kylheku.com>2015-09-08 07:01:42 -0700
commit94d029b0f24756b84a94ce2b3f8fd5739166b0c5 (patch)
tree8b12005298141f11225387bd75a3e38898f4e627 /txr.1
parentf72fa1121f2571aba9f16f95d58d8e915965d765 (diff)
downloadtxr-94d029b0f24756b84a94ce2b3f8fd5739166b0c5.tar.gz
txr-94d029b0f24756b84a94ce2b3f8fd5739166b0c5.tar.bz2
txr-94d029b0f24756b84a94ce2b3f8fd5739166b0c5.zip
New functions, subtypep and typep.
* eval.c (eval_init): Register subtypep and typep. * eval.h (list_s): Existing variable declared. * lib.c (atom_s, integer_s, number_s, sequence_s, string_s): new symbol variables. (subtypep, typep): New functions. (obj_init): Initialize new symbol variables. * lib.c (atom_s, integer_s, number_s, sequence_s, string_s): Declared. * txr.1: Documented type hierarchy and the new functions.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.1144
1 files changed, 144 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index bac8d8e6..5b173c78 100644
--- a/txr.1
+++ b/txr.1
@@ -12968,6 +12968,106 @@ is a symbol which names a special operator, otherwise it returns
.codn nil .
.SS* Object Type And Equivalence
+
+In \*(TL, objects obey the following type hierarchy. In this type hierarchy,
+the internal nodes denote abstract types: no object is an instance of
+an abstract type:
+
+.cblk
+ t ----+--- <cobj types> ---+--- hash
+ | |
+ | +--- stream
+ | |
+ | +--- random-state
+ | |
+ | .
+ | +... <others>
+ |
+ +--- <structures>
+ |
+ +--- sequence ---+--- string ---+--- str
+ | | |
+ | | +--- lstr
+ | | |
+ | | +--- lit
+ | |
+ | +--- list ---+--- null
+ | | |
+ | | +--- cons
+ | | |
+ | | +--- lcons
+ | |
+ | +--- vec
+ |
+ +--- number ---+--- float
+ | |
+ | +--- integer ---+--- fixnum
+ | |
+ | +--- bignum
+ |
+ +--- sym
+ |
+ +--- env
+ |
+ +--- pkg
+ |
+ +--- fun
+.cble
+
+In addition to the above hierarchy, the following relationships also exist:
+
+.cblk
+ t ---+--- atom --- <any type other than cons> --- nil
+ |
+ +--- cons ---+--- lcons --- nil
+ |
+ +--- nil
+
+ sym --- null
+.cble
+
+That is to say, the types are exhaustively partitioned into atoms and conses;
+an object is either a
+.code cons
+or else it isn't, in which case it is the abstract
+type
+.codn atom .
+
+The
+.code cons
+type is odd in that it is both an abstract type,
+serving as a supertype for the type
+.code lcons
+and it is also a concrete type in that regular conses are of
+this type.
+
+The type
+.code nil
+is an abstract type which is empty. That is to say, no object is of
+type
+.codn nil .
+This type is considered the abstract subtype of every other type,
+including itself.
+
+The type
+.code nil
+is not to be confused with the type
+.code null
+which is the type of the
+.code nil
+symbol.
+
+Lastly, because the type of
+.code nil
+is the type
+.code null
+and
+.code nil
+is also a symbol, the
+.codn null
+type is a subtype of
+.codn sym .
+
.coNP Function @ typeof
.synb
.mets (typeof << value )
@@ -13023,6 +13123,50 @@ A bignum integer: arbitrary precision integer that is heap-allocated.
There are additional kinds of objects, such as streams.
+.coNP Function @ subtypep
+.synb
+.mets (subtypep < left-type-symbol << right-type-symbol )
+.syne
+.desc
+The
+.code subtypep
+function tests whether
+.meta left-type-symbol
+and
+.meta right-type-symbol
+name a pair of types, such that the left type is a subtype of the right
+type.
+
+Each type is a subtype of itself. Most other type relationships can be inferred
+from the type hierarchy diagrams given in the introduction to this section.
+
+In addition, there are inheritance relationships among structures. If
+.meta left-type-symbol
+and
+.meta right-type-symbol
+both name structure types, then
+.code subtypep
+yields true if the types are the same struct type, or if the right
+type is a direct or indirect supertype of the left.
+
+.coNP Function @ typep
+.synb
+.mets (typep < object << type-symbol )
+.syne
+.desc
+The
+.code typep
+function tests whether the type of
+.meta object
+is a subtype of the type named by
+.meta type-symbol .
+
+The following equivalence holds:
+
+.cblk
+ (typep a b) --> (subtypep (typeof a) b)
+.cble
+
.coNP Function @ identity
.synb
.mets (identity << value )