4 ms·
> Is there a good reason for VMs to support TCO rather than having compilers perform it? Again this word! Proper tail calls handling is not an "optimisation".
by sklogic 12y ago
> Is there a good reason for VMs to support TCO rather than having compilers perform it?
Again this word! Proper tail calls handling is not an "optimisation". Optimisations are supposed to be optional, while tail calls handling makes a semantic difference.
And, no, compilers cannot do it statically. You cannot statically resolve virtual calls, for example. Consider the following trivial case:
`(define (f g x) (g x))`
> When do you want this? There's sun.misc.Unsafe#setMemory if you really need it.
Try implementing, say, an STG efficiently. Or even a WAM.
> Might be added in JVMS 10 or some version thereafter.
JVM may start to suck less at some point. But now it sucks.
> but it wasn't designed as a general purpose compilation target like llvm.
Exactly. And that's why it's inferior to the other VMs, which were designed with multiple source language semantics in mind. Including even CLR.