Synchronized classes have no public members

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


On 10/14/15 6:33 AM, flamencofantasy wrote:
> On Tuesday, 13 October 2015 at 19:05:31 UTC, 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.
>
> +1
>
> Please remove synchronized all together. It's an abomination which
> should have never been in D in the first place.
> It encourages sloppiness and lobotomizes programmers!
> The greatest good you can do to all the D code out there that makes use
> of synchronized is to kill synchronized.
> Then they'll have to think and hopefully learn how to properly
> synchronize sections of code instead of locking everything everywhere
> all the time.

Scoped locking as embodied by "synchronized" has many meaningful uses. 
Facebook uses 
https://github.com/facebook/folly/blob/master/folly/docs/Synchronized.md 
often and with great results. C++1x has made it a language rule that the 
entire STL implements mutable and const methods as expected by 
folly::Synchronized. -- Andrei


More information about the Digitalmars-d mailing list