Our approach makes it quite easy to mess up the structure of our structured concurrency:
import hxcoro.CoroRun;
function main() {
CoroRun.runScoped(node -> {
node.async(_ -> {
node.async(_ -> trace("uhm"));
});
});
}
This is clearly supposed to create a child scope, but because we used _ instead of node for some reason we end up with a sibling scope instead.
I think this would require the notion of variables that cannot be captured. This is easy enough to implement in the compiler, the only question is how it should be communicated from user code. We don't want any additional syntax in the node -> part, so the only solution would be to have some kind of tag on the type of the variable or argument. Maybe something like @:noCapture interface ICoroNode would work.
Although now that I'm writing this, I realize that this wouldn't actually work because we're hoisting the variable. Hmm...
Our approach makes it quite easy to mess up the structure of our structured concurrency:
This is clearly supposed to create a child scope, but because we used
_instead ofnodefor some reason we end up with a sibling scope instead.I think this would require the notion of variables that cannot be captured. This is easy enough to implement in the compiler, the only question is how it should be communicated from user code. We don't want any additional syntax in the
node ->part, so the only solution would be to have some kind of tag on the type of the variable or argument. Maybe something like@:noCapture interface ICoroNodewould work.Although now that I'm writing this, I realize that this wouldn't actually work because we're hoisting the variable. Hmm...