Safe reference counting cannot be implemented as a library

sclytrack via Digitalmars-d digitalmars-d at puremagic.com
Sat Dec 5 14:06:33 PST 2015


On Monday, 2 November 2015 at 09:56:14 UTC, Ola Fosheim Grøstad 
wrote:
> On Sunday, 1 November 2015 at 22:04:51 UTC, deadalnix wrote:
>> On Sunday, 1 November 2015 at 20:55:00 UTC, Martin Nowak wrote:
>>> On 11/01/2015 09:51 PM, Martin Nowak wrote:


http://lists.puremagic.com/cgi-bin/mailman/listinfo/dlang-study


The last post on the study group ended a while ago. Does that 
mean it is not going forward. It suggest to talk about lifetime. 
Is that with or without talking about
reference counting simultaneously?

What approach will be taken?


1) Will for every assignment to the object a hidden temporary be 
created by the compiler to keep the object alive.

RCObject obj = new RCObject();
Item item = obj.items[x];

_temp1 = obj;       //The compiler inserts this automatically and 
is not seen.
obj=new RCObject();


2) Will you disable the item by some magical way? Item might 
still be valid.

RCObject obj = new RCObject();
...
Item item = obj.items[x];

obj=new RCObject();
//item is no longer accessible beyond this point.
writeln(item); //error


3) Somehow disable the RCObject for the duration of the borrowing.

with(Item item = RCObject.items[x])
{
   writeln(item)
}


4) Solved by eating pizza or watching a movie ...



Maybe the discussion should be a tree.




More information about the Digitalmars-d mailing list