pass-by-ref semantics for structs (was Deque impl.)

Steven Schveighoffer schveiguy at yahoo.com
Thu Jan 31 12:33:33 PST 2013


On Thu, 31 Jan 2013 14:22:24 -0500, Maxim Fomin <maxim at maxim-fomin.ru>  
wrote:

> On Thursday, 31 January 2013 at 18:59:20 UTC, Steven Schveighoffer wrote:
>> Structs by default are easily destroyed from the stack, but lack the  
>> fundamental cogs to get GC-based destruction.
>>
>> -Steve
>
> Perhaps _d_newitemT() and buddies can check whether it creates structs,  
> store a collection of pointers to structs it allocates and at the end of  
> program some druntime routine loops through out of the collection to run  
> dtors?

What is needed is a precise GC, where the struct typeinfo and destructor  
are stored along with the block.

However, we ALSO need two functions, a destructor (Called from the stack  
deterministically) and a finalizer (called from the GC).

Like I said, this isn't an unsolvable problem, but neither is making  
classes reference counted.

-Steve


More information about the Digitalmars-d mailing list