How to cast `shared` away reliably

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Thu Feb 12 01:43:47 UTC 2026


On 12/02/2026 2:14 PM, Arafel wrote:
> These rules make sense (perhaps) for |const|, but certainly not for | 
> shared| that it /expected/ to be removed. If the language /forces/ me to 
> cast away shared (and, for the record, I agree with that), it should be 
> easy and straightforward.
> 
> There should be a clear way to say: "Hey, all locks in place, now it's 
> safe. Give me my variable back exactly as it was, so I can actually do 
> some work."
> 
> This just forces one to go through (even more) hoops and loops to be 
> able to use a |shared| variable, especially in generic code. And, in 
> fact, it's even messier if you add complex types, like |shared 
> (RefCounted!S[string])| and / or |shared(RefCounted!S[])|.


https://forum.dlang.org/post/pwhgwshfxfunwtflhmfz@forum.dlang.org



More information about the Digitalmars-d mailing list