fake RefCounted for CTFE?

Steven Schveighoffer schveiguy at gmail.com
Tue Jun 16 00:28:11 UTC 2020


On 6/15/20 8:03 PM, tsbockman wrote:
> On Monday, 15 June 2020 at 21:18:23 UTC, Steven Schveighoffer wrote:
>> Would it make sense for RefCounted to turn into GC for CTFE mode? That 
>> is, if RefCounted is used during CTFE, it just allocates on the GC 
>> heap and doesn't actually do ref counting. ...
>> What do you think?
> 
> Ref counting isn't only for memory management - sometimes it's used to 
> ensure that a value's destructor will run at a logical point in time. 
> Using the garbage collector during CTFE instead of malloc/free or 
> whatever should be fine, but some thought would need to be put into 
> whether there are any other valid uses of destructors during CTFE.

Yeah, this is a good point.

It could still run the destructor, but not free the memory. So instead 
of marking it as not truly ref-counted, just mark it as not needing to 
be freed.

-Steve


More information about the Digitalmars-d mailing list