I wish all qualifiers were revisited with an eye for simplification

Timon Gehr timon.gehr at gmx.ch
Tue Aug 4 17:15:23 UTC 2020


On 04.08.20 04:13, Andrei Alexandrescu wrote:
> On 8/3/20 5:56 PM, Manu wrote:
>> I think shared has potential to offer critical benefit to D, and we've 
>> talked about this personally to some length. Don't kill it yet, let's 
>> try and fix it. Although it's worth recognising that if we don't fix 
>> it, then it might as well be killed as it stands today.
> 
> Of course fixing it would be great!

It's being fixed, but Manu's vision for "fixing" it is really to do more 
than fixing it.  Manu thinks "unshared" is useless as a type qualifier.

He wants to change the meaning of `shared` so it no longer means 
"shared", but instead means "thread safe". For plain variables, this 
"thread safe" annotation would also imply "shared" (in an unprincipled 
manner, breaking the type system).

"thread safe" is to "shared" approximately as "const" is to "mutable". 
That's also why all variables can implicitly convert to "thread safe".

> I'm glad you pushed the restriction 
> through. At least now generic code could see `shared` as "shrouded in 
> opacity, not subject to the usual operations".

Luckily the restriction makes sense for `shared` even if its meaning is 
not changed to be different from its name.


More information about the Digitalmars-d mailing list