Backward type inference in SBCL?

Vasily Postnicov <[email protected]> Sun, 29 Sep 2024 06:05:28 +0000
Newsgroups gmane.lisp.steel-bank.general
Message-ID <CADnZ6BkKgDKpb9trGRTxNtKeXChGzbCKpwdmE4DJqC2kkuRixw@mail.gmail.com>
Hi! I am learning SBCL internals in order to teach the compiler to generate
more optimal code. I've noticed that a type of a function's result can be
derived from types of its arguments by writing a DERIVE-TYPE optimizer
using DEFOPTIMIZER. Is there a mechanism which can improve the compiler's
knowledge about the types of arguments based on a current knowledge about
the types of arguments and the result?

E.g. if we have NUMBER + SINGLE-FLOAT = DOUBLE-FLOAT, then the first arg of
+ must be DOUBLE-FLOAT

I am curious because I want to improve my cl-forward-diff library which
adds a new numeric type and provides its own math functions for automatic
differentiation. I want to go a bit further and make type inference to play
nicely with those functions.

_______________________________________________
Sbcl-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-help