3 ms·
> unless the compiler isn't doing what is essentially a type level equivalent of tail call elimination It doesn't, why would it? That's a pretty niche thing to
by Manishearth 10y ago
> unless the compiler isn't doing what is essentially a type level equivalent of tail call elimination
It doesn't, why would it? That's a pretty niche thing to have.
> finding the type of that function should be trivial unless the return type can become recursive with unbounded depth.
The return type is recursive with unbounded depth. The typechecker doesn't know the value of `n`, so to it this returns an infinitely recursive type.
Closures are statically dispatched. If you want something like this to work, you should box them as a trait object so that they get dynamically dispatched.