So, at least @Benny is of the opinion that it has to be that way, i.e. that inference of non-SSA captures will always and unavoidable suck.
But additionally, it sucks extra hard, because the lowering is dumb. E.g.
function f()
x = 0
if false x = 1 end
g()=x
g()
end
gleefully infers as Any. This is because lowering is dumb and only sees the AST, and neither CFG nor const-prop nor escape analysis nor anything!
I tend to agree with @Benny, the problem is hard, and it will always suck. But it doesn’t need to suck that badly.
Regardless, it has been that way for 8+ years. I think it is disingeneous to pretend that boxing of captures will be solved “with the attack Keno”.
Even if we somehow got much better optimization, by deferring boxing decisions to later optimization stages that have CFG, type inference and escape analysis available, the semantics of captures mean that we will box a lot.
I see a much brighter future for a command-line switch that emits warnings for all boxed captures – i.e. for everything that is not capture-by-value.
And then a slow community shift to always enable that switch, and thus transition to a julia dialect / subset that has capture-by-value.
(due to macros and generated functions, boxing cannot be statically decided / linted, you really must hook the compiler in order to be able to warn users that they wrote really bad code)