It would need to be made obvious that these are generic functions/structs, because they won't be interchangeable.
fn foo<T: fn(int, int)>(x: T, y: int) { x(5, y) }
Every closure would have either a unique type (like C++ closures) or at least a type based on the environment. A stack closure would start off as a bare moveable fn(...) implementation able to be converted to boxed &fn(...), ~fn(...) or Rc<fn(...)> objects.
An unboxed closure would just be static dispatch without a function pointer. As with traits, you would choose between static/dynamic dispatch.
It would need to be made obvious that these are generic functions/structs, because they won't be interchangeable.
Every closure would have either a unique type (like C++ closures) or at least a type based on the environment. A stack closure would start off as a bare moveable
fn(...)implementation able to be converted to boxed&fn(...),~fn(...)orRc<fn(...)>objects.An unboxed closure would just be static dispatch without a function pointer. As with traits, you would choose between static/dynamic dispatch.