Stream: contributing

Topic: Implementing type-erased closures


view this post on Zulip Ayaz Hafiz (Jul 14 2023 at 01:04):

If anyone is interested, I have a well-scoped project that could use some help - compiling type-erased closures to WASM and dev compilation backends, and supporting their reference counting.

Most languages implement closures by "type erasure" of the values that they capture, hiding them away somewhere on the heap and loading them only when needed. Roc generally does not use this scheme, because it begets various useful optimizations. However, in some cases, type erasure of closures will be required in the future, and in other cases it is useful to have as an option.

https://github.com/roc-lang/roc/pull/5576 implements initial support for type-erased closures for the LLVM backend, but there are several things missing:

With the exception of the last bullet, none of these require significant knowledge of the rest of the Roc compiler's implementation. I won't claim that these are easy, but they are small and well-scoped projects that you could sink into if you wanted to.

If anyone is interested, please follow up on this thread or DM me and I am happy to help you get started.


Last updated: Jul 06 2025 at 12:14 UTC