[Issue 14251] synchronized (mtx) doesn't check attributes (pure, const)
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Aug 27 00:57:15 PDT 2016
https://issues.dlang.org/show_bug.cgi?id=14251
--- Comment #11 from ZombineDev <petar.p.kirov at gmail.com> ---
A const reference to an object may actually refer to a immutable object. If
such object sits in ROM than failure of the compiler to prevent such error
(modification of the monitor) may have bad consequences (depending on the
implementation). Also most of the time, an object is being synchronized to
ensure exclusive write access to it. However there's no point in that if the
object is not mutable.
As for pure, personally I don't think that pure functions should be allowed to
cause a deadlock (I consider it to be a global side effect). Furthermore, 99%
of the time synchronized is used on shared objects, which pure functions have
no business looking at.
--
More information about the Digitalmars-d-bugs
mailing list