Very limited shared promotion

Walter Bright newshound2 at digitalmars.com
Tue Jun 18 02:54:10 UTC 2019


On 6/17/2019 7:03 PM, Timon Gehr wrote:
> Walter is thinking about making it unsafe to pass two mutable pointers to the 
> same object into a function by `ref`. For simple cases like your example, where 
> x is a local variable, I think a slightly adapted version of the algorithm he 
> has in mind would work too.

I suggest instead making `x` shared. Then cast it to unshared when protected 
with a mutex.

All this trying to find ways to convert local references to shared make code 
very very difficult to reason about, even if you didn't make a mistake. Worse, 
making them "implicit" conversions mean they can lie hidden in the code, so you 
don't even know it's happening.


More information about the Digitalmars-d mailing list