Where are the semantics of shared defined?

rsw0x via Digitalmars-d digitalmars-d at puremagic.com
Sat Aug 15 10:06:18 PDT 2015


On Saturday, 15 August 2015 at 09:30:48 UTC, Jonathan M Davis 
wrote:
>
> On the whole, if you understand how a variable in C/C++/C#/Java 
> works, you understand how shared works. It's just that unlike 
> C++, normal variables in D are thread-local, and shared is 
> protected against interacting with them in a manner which 
> violates that, and some non-atomic operations are illegal to 
> protect you from shooting yourself in the foot.
>
> So, the spec probably needs more information on shared in it, 
> but there really isn't much to put.
>
> - Jonathan M Davis

I'm not looking to understand how it works, I want to know 
exactly what the spec says which appears to be nothing. TDPL's 
only mention of casting away shared(13.14.4) is "if you are 
absolutely positive that the [...] list is completely private 
[...] you can cast away shared and use it without any regard to 
threads"

It says nothing on the legality of this, or if it's undefined 
behavior, so am I to assume that shared is at best a suggestion 
and not actually a guarantee? Feels like an addition C++ would 
get.


More information about the Digitalmars-d mailing list