Want reasonable reference counting? Disable automatic sharing of immutable

Ola Fosheim Grøstad ola.fosheim.grostad at gmail.com
Sat Nov 13 09:07:58 UTC 2021


On Friday, 12 November 2021 at 18:12:14 UTC, Andrei Alexandrescu 
wrote:
> On 2021-11-12 8:03, Timon Gehr wrote:
>> On 12.11.21 13:31, Steven Schveighoffer wrote:
>>>
>>> I've come to the conclusion, in order to fix this situation, 
>>> so `__mutable` really means mutable and `shared` is an 
>>> orthogonal piece, you need to remove the implicit sharing of 
>>> `immutable`.
>> 
>> I agree, that would be much better.
>
> We discussed this a couple of times. It's interesting. Sadly at 
> this point implicit thread sharing of immutable is so baked 
> into the language, it would take a lot of care to extricate. It 
> would be very difficult even for Timon or Paul.

Why? Just introduce ```readonly``` as a qualifier for unshared 
immutable and define ```immutable``` to be a shortcut for 
```shared``` + ```readonly```.



More information about the Digitalmars-d mailing list