[Issue 19984] New: Support shared in foreach lambdas
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Jun 19 03:30:57 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19984
Issue ID: 19984
Summary: Support shared in foreach lambdas
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: turkeyman at gmail.com
We want to arrive at a place where this code works:
struct S {
int result;
void inc(int i) shared { result.atomic!"+="(i); }
}
int sum(){
S s;
foreach(i; iota(1000).parallel){
static assert(is(typeof(s) == shared(S)));
s.inc(i);
}
static assert(is(typeof(s) == S));
return s.result;
}
In this example, the opApply delegate would be `int delegate(ref int) shared`.
--
More information about the Digitalmars-d-bugs
mailing list