Closures need to be isolated wrt a stack frame #602
Labels
Area/Lang
Relates to the Ballerina language specification
Type/Improvement
Enhancement to language design
Milestone
There is a complication with closures and isolated. Consider this:
This ought to work, but the closure passed to map is not isolated, because it accesses state outside its (the closure’s) parameters, namely k. From a type-checking point of the concept needs to be isolated wrt a specific stack frame. Declaring a function isolated means that is isolated wrt its own stack frame. The closure passed to map is isolated with respect to arrayInc’s stack frame. So the call to map is isolated with respect to arrayInc’s stack frame, so it’s OK for arrayInc to call it.
This also means we ought to infer the isolatedness of anoymous functions values within a function.
Originally posted by @jclark in #145 (comment)
The text was updated successfully, but these errors were encountered: