fake RefCounted for CTFE?
John Colvin
john.loughran.colvin at gmail.com
Tue Jun 16 13:36:28 UTC 2020
On Monday, 15 June 2020 at 21:18:23 UTC, Steven Schveighoffer
wrote:
> I'm doing some stuff with RefCounted for a factory-like
> expression, where I expect the factory harnesses are going to
> be very short-lived. However, these don't work at CTFE (because
> malloc/etc aren't available).
>
> 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.
> The end result will be a ref counted struct that somehow is
> flagged that it's never going away (and it shouldn't, if it's
> generated at compile time).
>
> Then you could use functions that return RefCounted items as
> static initializers, or use libraries that use RefCounted at
> compile time without issues.
>
> What do you think?
>
> -Steve
why not just have it continue doing ref-counting but use the GC
to do the allocating? Can't use GC.malloc at ctfe but `new
ubyte[](N)` works fine. You could even do a lambda cast to trick
it in to being nogc.
More information about the Digitalmars-d
mailing list