On Saturday, 20 October 2018 at 02:09:56 UTC, Dominikus Dittes
Scherkl wrote:
On Saturday, 20 October 2018 at 00:46:36 UTC, Nicholas Wilson
wrote:
Mutable = value may change
const = I will not change the value
immutable = the value will not change
unshared = I (well the current thread) owns the reference
shared = reference not owned, no unordered access, no
(unordered) writes
threadsafe = ???
unshared = the current thread owns the reference
threadsafe = I guarantee no race conditions or deadlocks will
occur
shared = every thread may have references
Exactly, "thredsafe" in nothing more than a contract between
programmers.
When you have "const" data, it is trivial for the compiler to
enforce that: it just doesn't allow you to mutate it. But the
compiler cannot reason about whether your logic is "threadsafe"
or not, there can be no static enforcement of "thread-safety". It
only holds as an implicit contract between programmers: the
authors of data and functions, and the users of that data and
functions, i.e. the API and the callers.