Non capturing local functions
This idea has been floated a few times in the coroutine stuff, basically some way to mark a local function as not being allowed to capture variables to prevent GC retention issues and potentially allow some targets to perform some optimisations.
I quite like the C# syntax for this which is to use the static keyword. i.e. a haxe version would be
function main() {
var i = 0;
static function foo() {
// compile error
i = 10;
}
foo();
}
I think this make some sense since we have static local variables, not sure about the anonymous function syntax though...
function main() {
var i = 0;
final foo = static () -> {
// compile error
i = 10;
}
foo();
}
Could also probably be done with some metadata, not sure whats easier / best. Wasn't sure if this should be a formal haxe evolution, but since I hasn't really been given any thought outside of "that seems nice" I thought I'd open an issue here first.
I like this idea a lot, will have to think it through though.
I like it too, but I'm really not sure about the use of static for this