<feed xmlns='http://www.w3.org/2005/Atom'>
<title>emacs, branch scratch/cl-types</title>
<subtitle>Emacs is the extensible, customizable, self-documenting real-time display editor. 
</subtitle>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/'/>
<entry>
<title>(cl-deftype): Don't set `cl-deftype-handler` directly</title>
<updated>2025-05-07T17:54:47+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2025-05-07T17:54:47+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=9f50fdf1e75040d7feaa1edb235377a33da94781'/>
<id>9f50fdf1e75040d7feaa1edb235377a33da94781</id>
<content type='text'>
In order to make it easier to change that in the future, let
`cl--define-derived-type` take care of storing the derived
type's function into `cl-deftype-handler`.

* lisp/emacs-lisp/cl-preloaded.el (cl--define-derived-type):
Change calling convention.  Set `cl-deftype-handler`.
* lisp/emacs-lisp/cl-macs.el (cl-deftype): Don't set `cl-deftype-handler`,
instead pass the function to `cl--define-derived-type`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In order to make it easier to change that in the future, let
`cl--define-derived-type` take care of storing the derived
type's function into `cl-deftype-handler`.

* lisp/emacs-lisp/cl-preloaded.el (cl--define-derived-type):
Change calling convention.  Set `cl-deftype-handler`.
* lisp/emacs-lisp/cl-macs.el (cl-deftype): Don't set `cl-deftype-handler`,
instead pass the function to `cl--define-derived-type`.
</pre>
</div>
</content>
</entry>
<entry>
<title>lisp/emacs-lisp/cl-types.el: Delete file</title>
<updated>2025-05-07T17:24:58+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2025-05-07T17:24:58+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=d7459da58de8bf317d7669f001c35244ba38d17b'/>
<id>d7459da58de8bf317d7669f001c35244ba38d17b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>cl-types: The big renaming to "derived types"</title>
<updated>2025-05-07T17:24:07+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2025-05-07T17:24:07+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=b13044dae3db9c449a93f52fecfd848a3e7dd67d'/>
<id>b13044dae3db9c449a93f52fecfd848a3e7dd67d</id>
<content type='text'>
`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) &lt;derived-types&gt;:
Rename from &lt;cl-types-of&gt;.  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`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`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) &lt;derived-types&gt;:
Rename from &lt;cl-types-of&gt;.  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`.
</pre>
</div>
</content>
</entry>
<entry>
<title>(cl-types-of): Fix two plain bugs</title>
<updated>2025-05-07T16:24:00+00:00</updated>
<author>
<name>David Ponce</name>
</author>
<published>2025-05-07T16:24:00+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=f6f35644b7f49732fe38fac3c199ef3a6a22abe7'/>
<id>f6f35644b7f49732fe38fac3c199ef3a6a22abe7</id>
<content type='text'>
* lisp/emacs-lisp/cl-extra.el (cl-types-of): Fix error handling.
Don't mutate `found` since it's stored as key in the hash-table.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lisp/emacs-lisp/cl-extra.el (cl-types-of): Fix error handling.
Don't mutate `found` since it's stored as key in the hash-table.
</pre>
</div>
</content>
</entry>
<entry>
<title>(cl-generic-generalizers): Fix typo in last change</title>
<updated>2025-05-07T03:04:46+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2025-05-07T03:04:46+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=2eb90d43e6e3b8325503d56c7778b9245b930d88'/>
<id>2eb90d43e6e3b8325503d56c7778b9245b930d88</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>(cl-generic-generalizers): Skip types that need arguments</title>
<updated>2025-05-07T02:53:01+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2025-05-07T02:53:01+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=147113b3b5a89b401448424dd01c4ac915ea6081'/>
<id>147113b3b5a89b401448424dd01c4ac915ea6081</id>
<content type='text'>
* lisp/emacs-lisp/cl-lib.el (cl-generic-generalizers) "cl-types-of":
make sure the atomic derived type is valid.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lisp/emacs-lisp/cl-lib.el (cl-generic-generalizers) "cl-types-of":
make sure the atomic derived type is valid.
</pre>
</div>
</content>
</entry>
<entry>
<title>cl-types: Integrate into CL-Lib</title>
<updated>2025-05-06T03:18:56+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2025-05-06T03:18:56+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=fc4d8ce9514dd45ab34dbef6f023347b42ee9fef'/>
<id>fc4d8ce9514dd45ab34dbef6f023347b42ee9fef</id>
<content type='text'>
* lisp/emacs-lisp/cl-extra.el (cl--type-unique, cl-types-of)
(cl--type-dispatch-list, cl--type-generalizer): Move to `cl-extra.el`.
(cl--type-generalizers): New function extracted from "cl-types-of"
method of `cl-generic-generalizers`.

* lisp/emacs-lisp/cl-lib.el (cl-generic-generalizers): New method to
dispatch on derived types.  Use `cl--type-generalizers`.

* lisp/emacs-lisp/cl-macs.el (cl-deftype): Move from `cl-types.el`
and rename from `cl-deftype2`.
(extended-char): Tweak definition to fix bootstrapping issues.

* lisp/emacs-lisp/cl-preloaded.el (cl--type-list, cl-type-class)
(cl--type-deftype): Move from `cl-types.el`.

* lisp/emacs-lisp/oclosure.el (oclosure): Don't abuse `cl-deftype` to
register the predicate function.

* test/lisp/emacs-lisp/cl-extra-tests.el: Move tests from
`cl-type-tests.el`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lisp/emacs-lisp/cl-extra.el (cl--type-unique, cl-types-of)
(cl--type-dispatch-list, cl--type-generalizer): Move to `cl-extra.el`.
(cl--type-generalizers): New function extracted from "cl-types-of"
method of `cl-generic-generalizers`.

* lisp/emacs-lisp/cl-lib.el (cl-generic-generalizers): New method to
dispatch on derived types.  Use `cl--type-generalizers`.

* lisp/emacs-lisp/cl-macs.el (cl-deftype): Move from `cl-types.el`
and rename from `cl-deftype2`.
(extended-char): Tweak definition to fix bootstrapping issues.

* lisp/emacs-lisp/cl-preloaded.el (cl--type-list, cl-type-class)
(cl--type-deftype): Move from `cl-types.el`.

* lisp/emacs-lisp/oclosure.el (oclosure): Don't abuse `cl-deftype` to
register the predicate function.

* test/lisp/emacs-lisp/cl-extra-tests.el: Move tests from
`cl-type-tests.el`.
</pre>
</div>
</content>
</entry>
<entry>
<title>cl-types: Simplify a bit further</title>
<updated>2025-05-05T18:57:05+00:00</updated>
<author>
<name>Stefan Monnier</name>
</author>
<published>2025-05-05T18:57:05+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=68a50324a70bd794d7f3228290310093f1515f7b'/>
<id>68a50324a70bd794d7f3228290310093f1515f7b</id>
<content type='text'>
Mostly, get rid of `cl--type-flag` and rely only on the presence/absence
of the type on `cl--types-list` to "flag" erroring-types.
Also, don't try and catch errors during dispatch.

* lisp/emacs-lisp/cl-types.el (cl--type-dispatch-list): Move to the
relevant section.
(cl--type-parents): Inline into sole caller.
(cl--type-deftype): Add `arglist` argument.
Don't signal an error if the type already existed but wasn't in
`cl--type-list` since that's normal and we can fix it.
Don't touch `cl--type-flag` any more.
Don't add to `cl--type-list` if it can't be used without arguments.
(cl-deftype2): Adjust call accordingly.
(cl--type-error): Inline into sole caller.
(cl-types-of): Be more careful to preserve ordering of types
before passing them to `merge-ordered-lists`.
Add `types` argument for use by dispatch.
Don't bother skipping the `root-type` since that's a built-in type,
so it should never happen anyway.
Don't catch errors if called from dispatch.
Don't bother with `cl--type-flag`.
(cl--type-generalizer): Use new arg of `cl-types-of` instead of
let-binding `cl--type-list`, in case `cl-types-of` ends up (auto)loading
a file or some such thing which needs to use/modify `cl--type-list`.
(cl--type-undefine): Move to end of file.

* test/lisp/emacs-lisp/cl-types-tests.el (cl-types-test): Remove DAG
test since we don't detect such errors any more.
Relax ordering test when the order is not guaranteed
by parent-relationships.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Mostly, get rid of `cl--type-flag` and rely only on the presence/absence
of the type on `cl--types-list` to "flag" erroring-types.
Also, don't try and catch errors during dispatch.

* lisp/emacs-lisp/cl-types.el (cl--type-dispatch-list): Move to the
relevant section.
(cl--type-parents): Inline into sole caller.
(cl--type-deftype): Add `arglist` argument.
Don't signal an error if the type already existed but wasn't in
`cl--type-list` since that's normal and we can fix it.
Don't touch `cl--type-flag` any more.
Don't add to `cl--type-list` if it can't be used without arguments.
(cl-deftype2): Adjust call accordingly.
(cl--type-error): Inline into sole caller.
(cl-types-of): Be more careful to preserve ordering of types
before passing them to `merge-ordered-lists`.
Add `types` argument for use by dispatch.
Don't bother skipping the `root-type` since that's a built-in type,
so it should never happen anyway.
Don't catch errors if called from dispatch.
Don't bother with `cl--type-flag`.
(cl--type-generalizer): Use new arg of `cl-types-of` instead of
let-binding `cl--type-list`, in case `cl-types-of` ends up (auto)loading
a file or some such thing which needs to use/modify `cl--type-list`.
(cl--type-undefine): Move to end of file.

* test/lisp/emacs-lisp/cl-types-tests.el (cl-types-test): Remove DAG
test since we don't detect such errors any more.
Relax ordering test when the order is not guaranteed
by parent-relationships.
</pre>
</div>
</content>
</entry>
<entry>
<title>cl-types.el: Speed up deftype and dispatch</title>
<updated>2025-05-05T15:03:56+00:00</updated>
<author>
<name>David Ponce</name>
</author>
<published>2025-05-05T15:03:56+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=8f649c42702144dbbacba180c78ab0df04951807'/>
<id>8f649c42702144dbbacba180c78ab0df04951807</id>
<content type='text'>
* lisp/emacs-lisp/cl-types.el (cl--type-list): Doc string.
(cl--type-dispatch-list): New variable.
(cl--type-parents): Make it a plain defun.
(cl--type-children, cl--type-dag): Remove.
(cl--type-undefine): Remove duplicate test for `cl--type-p'.  Use
`cl--class-children'.  Clear `cl--type-flag' instead of
`cl--type-error'.  Also remove type from the dispatch list.
(cl--type-deftype): Doc string.  Remove useless safeguard of
data on error.  Fix some error messages.  Clear `cl--type-flag'
when a type is (re)defined.  Just push new types on
`cl--type-list'.
(cl--type-error): Set `cl--type-flag' to the symbol `error' and
remove type in error from the dispatch list.
(cl-types-of): Doc string.  Remove useless check for
`cl-type-class-p'.  Skip types which we are sure will not match.
Simplify creation of the DAG.
(cl--type-generalizer): In the tagcode-function, check only types
that can be dispatched.
(cl-generic-generalizers): Populate the dispatch list.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lisp/emacs-lisp/cl-types.el (cl--type-list): Doc string.
(cl--type-dispatch-list): New variable.
(cl--type-parents): Make it a plain defun.
(cl--type-children, cl--type-dag): Remove.
(cl--type-undefine): Remove duplicate test for `cl--type-p'.  Use
`cl--class-children'.  Clear `cl--type-flag' instead of
`cl--type-error'.  Also remove type from the dispatch list.
(cl--type-deftype): Doc string.  Remove useless safeguard of
data on error.  Fix some error messages.  Clear `cl--type-flag'
when a type is (re)defined.  Just push new types on
`cl--type-list'.
(cl--type-error): Set `cl--type-flag' to the symbol `error' and
remove type in error from the dispatch list.
(cl-types-of): Doc string.  Remove useless check for
`cl-type-class-p'.  Skip types which we are sure will not match.
Simplify creation of the DAG.
(cl--type-generalizer): In the tagcode-function, check only types
that can be dispatched.
(cl-generic-generalizers): Populate the dispatch list.
</pre>
</div>
</content>
</entry>
<entry>
<title>(cl-types-of): Speed up by caching more of its work</title>
<updated>2025-04-29T14:48:37+00:00</updated>
<author>
<name>David Ponce</name>
</author>
<published>2025-04-29T14:48:37+00:00</published>
<link rel='alternate' type='text/html' href='https://jason.zzq.org/git/emacs/commit/?id=4323ff209f2f73ca4e6d389de69eb310988c0b1f'/>
<id>4323ff209f2f73ca4e6d389de69eb310988c0b1f</id>
<content type='text'>
* lisp/emacs-lisp/cl-types.el (cl--type-parents): Make it a proper function.
(cl--type-children): Use `cl--class-children` and make it a `defsubst`.
(cl--type-dag): η-reduce and make it a `defsubst`.
(cl--type-undefine): Also reset `cl--type-error`.
(cl--type-deftype): Modify `cl--type-list` atomically so we never need
to restore it upon error.  Don't test bogus parent here.
(cl-deftype2): Test bogus parent here instead.  Also, better preserve
the declarations for the lambda.
(cl-types-of): Do less uncached work.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* lisp/emacs-lisp/cl-types.el (cl--type-parents): Make it a proper function.
(cl--type-children): Use `cl--class-children` and make it a `defsubst`.
(cl--type-dag): η-reduce and make it a `defsubst`.
(cl--type-undefine): Also reset `cl--type-error`.
(cl--type-deftype): Modify `cl--type-list` atomically so we never need
to restore it upon error.  Don't test bogus parent here.
(cl-deftype2): Test bogus parent here instead.  Also, better preserve
the declarations for the lambda.
(cl-types-of): Do less uncached work.
</pre>
</div>
</content>
</entry>
</feed>
