diff options
| author | Stefan Monnier | 2025-05-07 13:24:07 -0400 |
|---|---|---|
| committer | Stefan Monnier | 2025-05-07 13:24:07 -0400 |
| commit | b13044dae3db9c449a93f52fecfd848a3e7dd67d (patch) | |
| tree | 51e3c6c264d6f2d66be41b4323592bc0b3464a8c /doc/misc | |
| parent | f6f35644b7f49732fe38fac3c199ef3a6a22abe7 (diff) | |
| download | emacs-b13044dae3db9c449a93f52fecfd848a3e7dd67d.tar.gz emacs-b13044dae3db9c449a93f52fecfd848a3e7dd67d.zip | |
cl-types: The big renaming to "derived types"
`cl-defstruct` also defines a type and is also in CL, so
"cl-type" is not precise enough to talk about those types
defined with `cl-deftype`. Use the term "derived type" to be
more clear, as is done in the HyperSpec.
* doc/misc/cl.texi (Derived types): Move `cl-deftype` to this
new subsection. Document the use of derived types as method specializers.
* lisp/emacs-lisp/cl-extra.el (cl--types-of-memo): Rename from
`cl--type-unique`.
(cl--derived-type-dispatch-list): Rename from `cl--type-dispatch-list`.
(cl--derived-type-generalizer): Rename from `cl--type-generalizer`.
(cl--derived-type-generalizers): Rename from `cl--type-generalizers`.
* lisp/emacs-lisp/cl-lib.el (cl-generic-generalizers) <derived-types>:
Rename from <cl-types-of>. Catch but don't hide errors when a derived
type cannot be used as an atomic type specifier.
* lisp/emacs-lisp/cl-preloaded.el (cl--derived-type-list): Rename from
`cl--type-list`.
(cl-derived-type-class): Rename from `cl-type-class`.
(cl--derived-type-class-make): Rename from `cl--type-class-make`.
(cl--define-derived-type): Rename from `cl--type-deftype`.
Diffstat (limited to 'doc/misc')
| -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 | ||