Want reasonable reference counting? Disable automatic sharing of immutable

Timon Gehr timon.gehr at gmx.ch
Mon Nov 15 05:22:37 UTC 2021


On 15.11.21 03:04, Walter Bright wrote:
> On 11/14/2021 12:18 PM, Timon Gehr wrote:
>> On 14.11.21 20:51, Walter Bright wrote:
>>> On 11/14/2021 10:25 AM, Timon Gehr wrote:
>>>> How do you manually deallocate an immutable payload?
>>>
>>> The same way it is done now. Call free().
>>>
>>> Calling free() on an object ends its lifetime. As I mentioned to 
>>> Steven, lifetime and mutability are independent attributes.
>>>
>>
>> I agree that they are independent attributes, but how does the 
>> compiler know that something is an allocation/deallocation function? 
>> (My suggestion was to annotate such functions __mutable.)
> 
> It's done in @live functions. The functions aren't annotated specially, 
> it's just that passing a pointer argument to a non-scope parameter means 
> the pointer value is transferred, and is no longer 'live' in the calling 
> function.

I am aware, but I don't see how it helps. Where is the curtain and how 
do you go behind it?


More information about the Digitalmars-d mailing list