Stream: compiler development

Topic: Type erasure


view this post on Zulip Ayaz Hafiz (Nov 11 2023 at 16:47):

To get erased closures working across the board, I think we need to

view this post on Zulip Brendan Hansknecht (Nov 11 2023 at 16:49):

That shouldn't be too hard to add to the dev backend. Fundamentally just an indirect call and some pointer data twiddling.

view this post on Zulip Brian Carroll (Nov 12 2023 at 08:58):

For the Wasm backend the call_indirect instruction requires a type signature for the called function.
It's like "call any function that takes two f32s and returns an i32".
So the IR will need to contain enough Layout info to do that. But we'll already need that just to actually pass the arguments and get the return value anyway!
There's a bit of bookkeeping too. All indirect callees have to be listed in a table in the module. But we already support this because of List.map and friends, which indirectly call Roc functions from Zig.

view this post on Zulip Brian Carroll (Nov 12 2023 at 08:59):

So I don't see any major issues.


Last updated: Jul 06 2025 at 12:14 UTC