Lionello Lunesu wrote:
I like shared/const/immutable as much as the next guy, but there are now
2x2x3=12 ways to decorate a variable. Furthermore, by either declaring
the variable globally or locally (stack), we end up with 24 possible
declaration. See the code at the end of this post.
The decision to make a variable a static class or module member is
independent of whether to make it shared or not.
Shared and const-level have to do with controlling access to the variable.
An immutable variable does not need to be declared shared.
Shared const is for publish-subscribe sort of deals.
Shared mutable is for cooperative writing to the variable.
The point of a shared local variable is to pass it to another thread or
set of threads, which will then be able to mutate it without trouble.