[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy
From: |
Stefan Monnier |
Subject: |
Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it |
Date: |
Fri, 01 Mar 2024 11:49:38 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
> -(defconst cl--typeof-types
> - ;; Hand made from the source code of `type-of'.
> - '((integer number integer-or-marker number-or-marker atom)
> - (symbol-with-pos symbol atom) (symbol atom) (string array sequence atom)
[...]
> +(defconst cl--type-hierarchy
[...]
> + (symbol keyword boolean symbol-with-pos)
[...]
> + (symbol-with-pos keyword))
How did you come up with `cl--type-hierarchy`?
Because, obviously, something changed here.
How is `keyword` a "direct subtype" of `symbol-with-pos`?
> +(defconst cl--direct-supertypes-of-type
> + (make-hash-table :test #'eq)
> + "Hash table TYPE -> SUPERTYPES.")
> +
> +(defconst cl--direct-subtypes-of-type
> + (make-hash-table :test #'eq)
> + "Hash table TYPE -> SUBTYPES.")
> +
> +(cl-loop for (parent . children) in cl--type-hierarchy
> + do (cl-loop
> + for child in children
> + do (cl-pushnew parent (gethash child
> cl--direct-supertypes-of-type))
> + do (cl-pushnew child (gethash parent
> cl--direct-subtypes-of-type))))
FWIW, I think we should create a "type descriptor" defstruct (from which
`cl--class` would inherit), and generalize the `cl--class` symbol
property to one that holds the type descriptor of the given name.
So you could get the direct parents of `integer` with something like:
(slot-value (get 'integer 'cl--class) 'parents)
[ And then `C-h o integer RET` should show the corresponding info. ]
> +(defconst cl--typeof-types nil
This can't make sense.
If you change it later with `push/setq` it should not be a "defconst".
So either arrange to compute its default value directly inside the
`defconst`, or use a `defvar`.
> +(maphash (lambda (type _)
> + (push (cl--supertypes-for-typeof-types type) cl--typeof-types))
> + cl--direct-supertypes-of-type)
Did you compare the resulting alist to the one we had before?
Remember that the order of "(direct or not) supertypes" in there is
important.
The current table has errors. I see for example:
(fixnum integer integer-or-marker number atom number-or-marker)
where `atom` should come *after* `number-or-marker`.
Stefan
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it,
Stefan Monnier <=
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it, Andrea Corallo, 2024/03/01
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it, Stefan Monnier, 2024/03/01
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it, Andrea Corallo, 2024/03/03
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it, Stefan Monnier, 2024/03/03
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it, Andrea Corallo, 2024/03/03
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it, Stefan Monnier, 2024/03/03
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it, Andrea Corallo, 2024/03/04
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it, Stefan Monnier, 2024/03/04
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it, Andrea Corallo, 2024/03/04
- Re: feature/type-hierarchy 8a63e50036f 1/5: * Define 'cl--type-hierarchy' and compute 'cl--typeof-types' from it, Stefan Monnier, 2024/03/04