4 ms·
And a modern compiler will jmp past the type checks if the inferencer OKs it!
by User23 1y ago
And a modern compiler will jmp past the type checks if the inferencer OKs it!
- aidenn0 1y agoWhich the inferencer probably can't do because of how dynamic standard-class can be. Also, if we want to get pedantic, method-dispatch does not dispatch on types in Common Lisp, but rather via EQL or the class of the argument. Since sub-classes can be made (and methods added or even removed) after a method invocation is compiled, there is no feasible way in a typical lisp implementation[1] to do compile-time dispatch of any type that is a subtype of standard-object. Now none of this prevents you from extending lisp in such a way that lets you freeze the method dispatch (see e.g. https://github.com/alex-gutev/static-dispatch https://github.com/alex-gutev/static-dispatch), but "a modern compiler will jmp past the type checks" is false for all of the CLOS implementations I'm familiar with. 1: SICL is a research implementation that has first-class global environments. If you save the global-environment of a method invocation, you can re-compile the invocation whenever a method is defined (or removed) and get static-dispatch. There's a paper somewhere (probably on metamodular?) that discusses this possibility.
- User23 1y agoVery interesting comment! To clarify, as you know CLOS isn’t the CL type system. I was particularly thinking about things like fixnum arithmetic. The CMUCL and SBCL manual sections on code generation discuss this and it can be verified with DISASSEMBLE.
- aidenn0 1y agoMissed your reply when it happened. Note that you cannot specialize a method on "fixnum" since it's not a class (though you can on "number" or "integer" since they are classes).