Concretely, you should be able to access Closure fields and methods without having to cast a Func into a Closure.
Func should really just be used to specify the type of the raw function pointer (thunk) stored by the Closure.
In the bundled sdk, this change has two small effects:
f: func (c: Closure) {}
g: Func(...) -> Int
// This is now allowed, Func types are compatible with Closure
f(g)
low_level_c_func: extern func (thunk, userData: Pointer) -> Int
doLowLevelStuff: func (f: Func) -> Int {
// No need to cast f to Closure to retrieve thunk and context
low_level_c_func(f thunk, f context)
}
In ooc-kean, this helps with cleaning up closures, since you can call free() without casting all your Funcs into Closures.
All in all, I believe this is the kind of small features that should be acceptable, since it is just a small quality of life improvement regarding two baked-in types that have been known to be a hassle to work together, while they effectively represent the same thing.
Concretely, you should be able to access Closure fields and methods without having to cast a Func into a Closure.
Func should really just be used to specify the type of the raw function pointer (thunk) stored by the Closure.
In the bundled sdk, this change has two small effects:
In ooc-kean, this helps with cleaning up closures, since you can call
free()without casting all your Funcs into Closures.All in all, I believe this is the kind of small features that should be acceptable, since it is just a small quality of life improvement regarding two baked-in types that have been known to be a hassle to work together, while they effectively represent the same thing.