Closed frabert closed 7 months ago
Why not use free variables?
Mainly ease of use and conciseness, no need to push and pop stuff from the stack.
I made the API backwards compatible by wrapping existing SQFUNCTION
s with an auxiliary function.
Seems like a cool idea to me even though there's a workaround. With the new function added, the only possible objection would be an extra pointer stored with the closure, maybe not used by some people. This is a very small objection (literally) but maybe larger if the data is wasted on pure squirrel closures. (just thinking out loud here)
@zeromus If it turns out it's a significant issue, I guess it could be hidden behind some ugly preprocessor flag to render it optional
Adds an additional argument to C functions in order to pass an additional pointer to arbitrary data, which allows - for example - to implement closures from C.
A new functionsq_newclosure
is augmented in order to reflect this.sq_newudclosure
is added in order to support this.This is a breaking change - existing codebases will refuse to compile. Maybe an auxiliary way can be found to render the additional parameter optional.