diff options
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/misc/cl.texi | 28 |
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 | |||
| 888 | error. | 888 | error. |
| 889 | @end defun | 889 | @end defun |
| 890 | 890 | ||
| 891 | @defmac cl-deftype name arglist forms@dots{} | 891 | @node Derived types |
| 892 | This 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{} | ||
| 895 | This macro defines a new type called @var{name}. | ||
| 896 | Types defined this way are called @dfn{derived types}. It is similar | ||
| 893 | to @code{defmacro} in many ways; when @var{name} is encountered | 897 | to @code{defmacro} in many ways; when @var{name} is encountered |
| 894 | as a type name, the body @var{forms} are evaluated and should | 898 | as a type name, the body @var{forms} are evaluated and should |
| 895 | return a type specifier that is equivalent to the type. The | 899 | return 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 |
| 924 | arguments to specify the type of sequence to return. @xref{Sequences}. | 928 | arguments to specify the type of sequence to return. @xref{Sequences}. |
| 925 | 929 | ||
| 930 | Contrary to Common Lisp, CL-Lib supports the use of derived types | ||
| 931 | as method specializers. This comes with a significant caveat: derived | ||
| 932 | types are much too flexible for Emacs to be able to automatically find | ||
| 933 | out which type is a subtype of another, so the ordering of | ||
| 934 | methods is not well-defined when several methods are applicable for | ||
| 935 | a given argument value and the specializer of one or more of those | ||
| 936 | methods is a derived type. To make the order more well-defined, a derived type | ||
| 937 | definition 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 | ||