| Thread overview | |||||
|---|---|---|---|---|---|
|
June 28, 2017 [Issue 17567] make shared methods callable on unshared objects (and covariant) | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17567 Andrei Alexandrescu <andrei@erdani.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrei@erdani.com --- Comment #1 from Andrei Alexandrescu <andrei@erdani.com> --- This is not possible. Thanks Timon Gehr for explaining this to me. Consider: shared int* p; struct S { int x; void func() shared { p = &x; } } void bug() { auto p = new S; p.func; ++p.x; } At this point we have threads getting shared access to x, but the current thread believes x is unshared. -- | ||||
June 28, 2017 [Issue 17567] make shared methods callable on unshared objects (and covariant) | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17567 Martin Nowak <code@dawg.eu> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |WONTFIX --- Comment #2 from Martin Nowak <code@dawg.eu> --- (In reply to Andrei Alexandrescu from comment #1) > At this point we have threads getting shared access to x, but the current thread believes x is unshared. It already seemed too simple to work out :). So this would only work with some inout flavor of shared which likely wouldn't be worth the trouble. -- | ||||
June 28, 2017 [Issue 17567] make shared methods callable on unshared objects (and covariant) | ||||
|---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=17567 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #3 from Walter Bright <bugzilla@digitalmars.com> --- (In reply to Martin Nowak from comment #2) > It already seemed too simple to work out :). We worked out the rules for implicit conversions (used for covariance/contravariance) back when we came up with const/shared/etc. It's best to derive these in isolation, and then apply them without needing to work it out again. (It's a lot like using the chain rule for derivatives. Derive the chain rule, prove it's correct, then just apply it as a given.) I've gone through the same process with scope conversions. I kept confusing myself until I finally sat down and worked up a chart with the rules, convinced myself that that was correct, and then just applied them without worrying about it. -- | ||||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply