FFI and functions and/or closures

pub fn schedule_timeout(callback : () -> Int, delay : Int) -> Unit = "env" "schedule_timeout"

When I attempt to use the FFI to directly pass a function or closure I get Invalid stub type. I assume that’s because doing so isn’t currently supported, which is pretty understanding at this point in the language.

I’m trying to do things like timers/intervals. I’m already working around this this limitation by having some scheduler logic inside moonbit code that has a single exported callback that will then delegate to the right interval timer callbacks, but I’m curious what the long-term thinking is on FFI and functions? I imagine that’ll be quite some time, if ever? I know the ABI isn’t stable yet.

We’re expecting to lift some restrictions this week (i.e. to be published next week). We’re focusing on this issue right now and we will provide an experimental solution soon.