www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - newCTFE Status October 2019

reply Stefan Koch <uplink.coder googlemail.com> writes:
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
Oct 15 2019
parent ikod <igor.khasilev gmail.com> writes:
On Tuesday, 15 October 2019 at 15:28:48 UTC, Stefan Koch wrote:
 Hello Boys and Girls,

 I am proud to announce that the following code now works with 
 newCTFE.
...
 If you have nasty nested ctfe exception testcases please share 
 them.

 Cheers,

 Stefan
Hello, It's nice to know that you keep moving forward! Regards!
Oct 15 2019