aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/misc/cl.texi28
1 files changed, 26 insertions, 2 deletions
diff --git a/doc/misc/cl.texi b/doc/misc/cl.texi
index 4bceddb8196..a1246b11a8a 100644
--- a/doc/misc/cl.texi
+++ b/doc/misc/cl.texi
@@ -888,8 +888,12 @@ floats. In all other circumstances, @code{cl-coerce} signals an
888error. 888error.
889@end defun 889@end defun
890 890
891@defmac cl-deftype name arglist forms@dots{} 891@node Derived types
892This macro defines a new type called @var{name}. It is similar 892@subsection Derived types
893
894@defmac cl-deftype name arglist [docstring] [decls] forms@dots{}
895This macro defines a new type called @var{name}.
896Types defined this way are called @dfn{derived types}. It is similar
893to @code{defmacro} in many ways; when @var{name} is encountered 897to @code{defmacro} in many ways; when @var{name} is encountered
894as a type name, the body @var{forms} are evaluated and should 898as a type name, the body @var{forms} are evaluated and should
895return a type specifier that is equivalent to the type. The 899return a type specifier that is equivalent to the type. The
@@ -923,6 +927,26 @@ The @code{cl-typecase} (@pxref{Conditionals}) and @code{cl-check-type}
923@code{cl-concatenate}, and @code{cl-merge} functions take type-name 927@code{cl-concatenate}, and @code{cl-merge} functions take type-name
924arguments to specify the type of sequence to return. @xref{Sequences}. 928arguments to specify the type of sequence to return. @xref{Sequences}.
925 929
930Contrary to Common Lisp, CL-Lib supports the use of derived types
931as method specializers. This comes with a significant caveat: derived
932types are much too flexible for Emacs to be able to automatically find
933out which type is a subtype of another, so the ordering of
934methods is not well-defined when several methods are applicable for
935a given argument value and the specializer of one or more of those
936methods is a derived type. To make the order more well-defined, a derived type
937definition can explicitly state that it is a subtype of others using the
938@var{decls} argument:
939
940@example
941(cl-deftype unsigned-byte (&optional bits)
942 (list 'integer 0 (if (eq bits '*) bits (1- (ash 1 bits)))))
943
944(cl-deftype unsigned-8bits ()
945 "Unsigned 8-bits integer."
946 (declare (parents unsigned-byte))
947 '(unsigned-byte 8))
948@end example
949
926@node Equality Predicates 950@node Equality Predicates
927@section Equality Predicates 951@section Equality Predicates
928 952