Synchronized classes have no public members

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Thu Oct 15 03:11:05 PDT 2015


On 10/13/15 10:05 PM, Dicebot wrote:
> On Tuesday, 13 October 2015 at 18:28:23 UTC, Marco Leise wrote:
>> Guys, sorry to break into your wishful thinking, but
>>
>>    synchronized(mutex) {}
>>
>> already works as you want it to since as long as I can think. Yes, it
>> takes a parameter, yes it calls lock/unlock on the mutex. :)
>
> Yes, and I am saying that it doesn't justify presence of `synchronized`
> keyword in the language at all, being historical legacy misfeature.

For a while we were of the opinion that we should let "synchronized" and 
"shared" be and move on with alternative features. Now we believe an 
incomplete language definition is damaging the language as a whole so we 
better make them fully defined and useful within their charter.

Lock-based synchronization has plenty of good uses and the scope locking 
defined by "synchronized" covers a large useful subset of it. We need to 
make it usable safely and without contortions, and this particular PR is 
a step along that way.

It's not a huge priority but since Andrej has only done the work, the 
main concern left is breakage of existing code, albeit much of that is 
incorrect or unnecessarily unsafe.


Andrei



More information about the Digitalmars-d mailing list