On Fri, Jul 23, 2021 at 2:12 PM Daphne Preston-Kendal <xxxxxx@nonceword.org> wrote:
 
(type-of x) gives you a datum, in CL land usually a symbol, that tells you what kind of thing x is. That’s the name of a type, vaguely corresponding to a record-type descriptor in R6RS terms (but applicable to every object in the system, not just user-defined records).

An example of a type that is not a symbol is (cons fixnum fixnum), and indeed (typep '(1 . 2) '(cons fixnum fixnum)) is true.  But in SBCL and ECL at least, (type-of '(1 . 2)) simply replies `cons`, and that's a valid response too.
 
This means you can’t portably implement polymorphic dispatch by storing type descriptors in a table (or similar) to avoid having to call every predicate in turn. This is also what I meant with Scheme generic functions being inherently incompatible with the CLOS/JVM/CLR approaches, which all use dispatch based on type descriptors (whatever those look like in the relevant runtimes) rather than predicates.

The way fast-generics works is to re-create the generic function every time a method is added.  Confusingly, the method-defining macro is called `define-generic`, but that could be changed.  The Chicken implementation dispatches at runtime in the interpreter, but it uses a compile-time-only macro to do so in advance in compiled code: with a little extra cleverness it should be possible to do the same in some other Schemes, and then fall back to the original portable method for the rest.