newCTFE Status October 2019

Stefan Koch uplink.coder at googlemail.com
Tue Oct 15 15:28:48 UTC 2019


Hello Boys and Girls,

I am proud to announce that the following code now works with 
newCTFE.

class IntExp : Exception
{
   this(int x)
   {
     super("");
     this.value = x;
   }

   int value;
}
void fthrow(int x)
{
     throw new IntExp(x);
}

int fn(int x)
{
     try
     {
         fthrow(x);
     }
     catch (IntExp e)
     {
         return e.value;
     }
     assert(0);
}

static assert (fn(22) == 22);



This means simple exception handling can now be done.
However calling destructors and other cleanup, is not yet 
implemented.

Nor will this work properly if the exception is thrown more than 
one level below the try catch block.
However having this feature work in a simple form is already a 
huge step forward.

Feel free to ask me anything related to newCTFE, or exceptions.

If you have nasty nested ctfe exception testcases please share 
them.

Cheers,

Stefan




More information about the Digitalmars-d mailing list