DIP74 - where is at?

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Sun Oct 11 21:19:25 PDT 2015


On Monday, 12 October 2015 at 03:59:04 UTC, Marco Leise wrote:
> Am Sun, 11 Oct 2015 07:32:26 +0000
> schrieb deadalnix <deadalnix at gmail.com>:
>
>> In C++, you need to assume things are shared, and, as such, 
>> use thread safe inc/dec . That means compiler won't be able to 
>> optimize them. D can do better as sharedness is part of the 
>> type system.
>
> With the little nag that `shared` itself is not fleshed out.

Well, it really should be better fleshed out, but the reality of 
the matter is that it actually works pretty well as it is. The 
problem is primarily that it's a pain to use - and to a certain 
extent, that's actually a good thing, but it does make it harder 
to use correctly. Better support for detecting when shared can be 
safely cast away would be nice. e.g. being able to do something 
like

synchronized(mutex_for_foo)
{
     // foo is now implicitly treated as thread-local
}
// foo is now treated as shared again

would be nice. However, figuring out how to do that safely is 
very tricky.

Ultimately though, I think that the problem with shared generally 
comes down to folks not liking the fact that you pretty much 
can't do anything with a shared variable until you cast away 
shared, but the fact that it won't let you do much is actually 
protecting you.

We do need to take another look at shared and see what we can do 
to improve it, but I'm sure that it's ultimately going to be much 
different from how it is now.

- Jonathan M Davis


More information about the Digitalmars-d mailing list