Proposal to make "shared" (more) useful

Kagamin spam at here.lot
Fri Sep 14 12:42:48 UTC 2018


On Friday, 14 September 2018 at 12:00:19 UTC, Arafel wrote:
> Since I think this is commonly agreed, I was only trying to 
> suggest a possible way to improve it (see my other messages in 
> the thread), that's it.

Well, indeed synchronized classes are already treated a little 
special, e.g. they don't allow public fields. As they are 
unlikely to be used in low-level multithreading, I think their 
behavior can be changed to provide a middle ground between C and 
D concurrency - java style: 
https://docs.oracle.com/javase/tutorial/essential/concurrency/syncmeth.html
If `synchronized` class is changed to not imply `shared`, then it 
all can work.
1. `synchronized` class won't imply `shared` (java disallows 
synchronized constructors because it doesn't make sense)
2. methods of a synchronized class are callable on both shared 
and unshared instances
3. maybe even make it applicable only to class, not individual 
methods

AFAIK Andrei wanted some sort of compiler-assisted concurrency, 
maybe he will like such proposal.


More information about the Digitalmars-d mailing list