Garbage Collection and gamedev - tl;dr Yes we want it, so let's solve it

RazvanN razvan.nitu1305 at
Mon Nov 23 03:53:04 UTC 2020

On Monday, 23 November 2020 at 03:44:02 UTC, Adam D. Ruppe wrote:
> On Monday, 23 November 2020 at 03:27:48 UTC, RazvanN wrote:
>> I've been looking into this and the main issue that has caused 
>> slow progress in templatizing the runtime is the fact that the 
>> hooks need to be `@trusted pure @nogc nothrow`. Why? Because 
>> those hooks may get called from `@trusted pure @nogc nothrow`
> @trusted I understand, but the others should be correctly 
> inferred be a template anyway and if they can't be.... so be 
> it. There are already druntime functions you can't use from 
> @nogc, they're just special cased in the compiler instead 
> picked up from the implementation...

What about purity? If your code is pure but the runtime hook is 
not? And then there are many functions like this in druntime:

void checkSomething(T)(T a) @trusted nothrow @nogc
     /* some other checks */
     assert(a != fun(), "Fail");
     /* some other checks */

Let's say this function is used everywhere in druntime. You 
cannot mark it as pure because the compiler will then optimize it 
away and if you need it you just have to duplicate the code. Also 
if you want to format the message of the assert, normally you 
would use `~` however, you want your function to be @nogc so then 
you have to use the existing crippled AssertFormat in druntime 
which may not be enough for your needs.

My point is that you have to work around a lot of hindrances to 
implement this.

More information about the Digitalmars-d mailing list