Decorated non-escaping closures?

The problem is exclusivity. Two nonescaping closures can capture the same value for mutation, but the tradeoff is that those nonescaping closures must not possibly run at the same time. Since producer and consumer come from the same scope, they could potentially access the same mutable captures, and so you can't pass producer or a closure that captures producer as a parameter to consumer, since consumer will exclusively access the same capture scope as producer while it runs, so there would be no safe way for it to invoke producer, not without some new annotation to require the two closures have disjoint captures or something like that.

That's a bug.

1 Like