digitalmars.D.bugs - [Issue 6823] New: Shared Delegates Should Implicitly Cast to Nonshared
- d-bugmail puremagic.com (36/36) Oct 17 2011 http://d.puremagic.com/issues/show_bug.cgi?id=6823
http://d.puremagic.com/issues/show_bug.cgi?id=6823 Summary: Shared Delegates Should Implicitly Cast to Nonshared Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: major Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: debio264 gmail.com --- Comment #0 from Andrew Wiley <debio264 gmail.com> 2011-10-17 23:58:06 PDT --- Code Example: synchronized class Thing { void doSomeWork(void delegate() work) { work(); } void work() {} } void main() { auto th = new Thing(); th.doSomeWork(&th.work); } This example won't compile because the type of `&th.work` is `void delegate() shared`, which will not implicitly convert to `void delegate()`. This type is probably correct - it's safe to share that delegate between threads, but since it's also safe to NOT share that delegate between threads, the delegate should implicitly cast to non-shared. This is a large problem for code using shared data because `void delegate() shared` does not parse as a type. The current workaround is to insert a cast to `void delegate()` at the call site. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 17 2011