synchronized - shared but actually useful

FeepingCreature feepingcreature at gmail.com
Wed Oct 31 07:00:32 UTC 2018


On Tuesday, 30 October 2018 at 18:38:48 UTC, Jonathan M Davis 
wrote:
> But shared is a low level construct and should stay that way. 
> It's the base for everything else.
>

This is simply not correct. People didn't stop having a need for 
threading while D was figuring out how to unbreak shared for ten 
years and counting. Fact is, the base for everything else is 
__gshared and synchronized, and it will *continue* to be 
__gshared and synchronized unless __gshared is removed and the 
Thread constructor is changed to only take shared delegates.

Why not do something useful with synchronized instead?

> And to be honest, I don't really expect it to be reasonable to 
> add much in the way of higher level mechanisms for sharing data 
> to D at the language level - not with it being a systems 
> language. Most stuff would require restricting it further 
> and/or introducing a serious ownership model to it, which we 
> really don't want to do. Even synchronized classes are pretty 
> questionable, because they can only safely remove the outer 
> layer of shared, which is arguably better than nothing, but it 
> doesn't get you very far. Without a full-blown ownership model, 
> we're pretty much reduced to manual casting when mutexes or 
> synchronized are used, and the language really isn't going to 
> be much help. If someone can come up with some bright ideas, 
> great. All the more power to them. Maybe we can improve the 
> situation. But again, they should be built on top of shared as 
> a low level mechanism, not try to change what shared is.
>
> - Jonathan M Davis


Sorry, but can you please actually comment on my proposal in 
concrete terms rather than handwave about how we're reduced to 
manual casting (which is not necessary for concurrency at the 
moment, so I'm not sure why you think it's unavoidable), and how 
the language surely cannot be of much help without even 
commenting on a proposal for how it *could* actually be of help?


More information about the Digitalmars-d mailing list