Callbacks and retention

A function parameter can describe a callback's argument and result types. That signature says nothing about whether foreign code retains the callback or invokes it from another thread. The example checks a declaration only.

@queued, @blocking and @ffi_retain_callbacks are retired. A retained callback needs an owning registration that keeps its captures alive until the native side acknowledges that calls have stopped. A queued callback also needs checked payload transfer and queue ownership.

These source APIs are not available yet. Removing the old annotation does not make retaining a callback safe, and unsafe does not establish a lifetime proof. Do not pass a closure to a retaining native API using this declaration alone.

extern fn store_callback(callback: fn(i32) -> i32) -> i32

fn main() {}
Run locally
moon check main.mn
Ctrl/⌘+Enter checks the current lesson.