I implemented the Nimble type inference algorithm from Henry Baker's old Common Lisp paper in Clojure awhile back for #reasons. It's based on lattice/algebraic data flow (Kaplan-Ullman) rather than logical unification (Milner), and works well to calculate type specialization while compiling dynamic languages:

https://www.plover.com/misc/hbaker-archive/TInference.html

Yesterday I added a simple C generator to make something like Pre-Scheme <https://prescheme.org> for #Clojure

I couldn't leave it alone, so now it correctly refuses to emit C until it can ground every expression in a C-compatible type (type hints can be used to resolve ambiguities), and the generated C compiles to perfectly good WASM modules. This is now dangerously close to being useful. 🤔
Okay, it now emits Zig and the process to get native and WASM modules out is very straightforward. I think the next step is adding array support so I can compile numeric code written interactively in Clojure to fast native code. It might be interesting to automatically generate JNA bindings so one can livecode native modules that get loaded into the JVM on the fly? 🤔
@jack would it be possible to see your source code? I'm kinda struggling to understand the paper properly.
@abnv I’ll release it at some stage, once it tells me what it really wants to be.
@jack wow, exactly what I was looking for today to implement in my compiler for a JS like dynamically typed language. Thanks! Do you think it would work my non-lisp language?
@abnv O, sure, the algorithm doesn’t care about syntax :)
@jack great. Thanks for posting it. I can't tell you how opputune it is for me.

@jack which, obvs, fails when it hits the bignum transition.

#Lisp-like languages are not good just because they handle recursion well -- #Clojure, running on the limited and unextensible JVM stack, does not handle recursion well -- but because when a result cannot fit into one storage type, you can return it as another storage type, because data items are tagged with their type.

You cannot easily move automatically between int32 and int64 in C, let alone between int64 and a bignum library.

@jack why not take over #prescheme since it got abandoned it looks like. https://codeberg.org/prescheme/prescheme
prescheme

Port of the Pre-Scheme compiler to R7RS

Codeberg.org

@nixfreak So far as I know Andrew Whatson is still working on it.

In any case, I have made a few design decisions that differ from theirs (type inference algorithm, source language, I'll probably switch to generating Zig instead of C, &c).

@jack oh ok I’ve been told by multiple individuals that it’s stalled, but that’s good.