Open BryantLam opened 5 years ago
I'm in favor of something like this for task and locale private, but I'm not sure we want to expose something like thread_local. While tasks will almost certainly be hosted on system threads in some way, threads aren't part of the language. thread_local storage is also pretty hard to use under tasking layers where tasks can migrate between threads.
For now, I'm okay with focusing this feature on definitely considering locale-private variables, neutrally considering task-private variables, and shelving thread-private variables.
For task-private variables, is there a use case for the following?
task_private var x = 0;
begin {
x += 1;
writeln(x);
}
{
x += 2;
writeln(x);
}
Today, this code (without task_private
) does not work because:
note: The shadow variable 'x' is constant due to task intents in this begin statement
which is appropriate. Possible complications include tasks that spawn more tasks: how would those task-private variables be propagated? I'm less certain about how this feature should be designed.
Related #12281
Feature request. Today, declaring a module global variable creates that variable on locale 0. Is there thought to supporting additional global-variable attributes that change the storage duration of these global variables to e.g.: