5 ms·
Tailcalls is something that a language compiler that targets VM bytecode cannot easily address by itself and ideally needs cooperation from the VM. I'm not awa
by neonsunset 2y ago
Tailcalls is something that a language compiler that targets VM bytecode cannot easily address by itself and ideally needs cooperation from the VM.
I'm not aware of implementation details of either Clojure or Kotlin but if it is anything like F#, then I would really not hold tailcalls against either of them.
In order to effectively support FP languages, CIL specification defines tail. prefix for call, calli and callvirt opcodes, and CoreCLR fully supports it except scenarios outlined by the spec.
Does JVM bytecode specification have something like this?
Edit: Turns out F# compiler does additional heavy lifting besides emitting the prefix https://github.com/dotnet/fsharp/blob/main/docs/large-inputs-and-stack-overflows.md https://github.com/dotnet/fsharp/blob/main/docs/large-inputs...
- kragen 2y agointeresting, thanks! any idea what the situation is like on wasm?
- neonsunset 2y agoWASM does appear to have significant tailcall consideration: https://github.com/WebAssembly/tail-call/blob/main/proposals/tail-call/Overview.md https://github.com/WebAssembly/tail-call/blob/main/proposals...
- kragen 2y agothe high bit here seems to be 'Currently, the Wasm design explicitly forbids tail call optimisations'?
- neonsunset 2y agoI'm not keeping up closely with WASM development, but doesn't it say this was the case at the time the proposal was written? It seems it goes quite extensively into the subject which is a good look for WASM (which I'm otherwise on the fence about when it comes to using it outside of browser scenarios).