On 4/4/2017 8:13 AM, deadalnix wrote:
Then just do:
auto ePtr = malloc(...);
auto e = *(cast(Exception*) &ePtr);
throw e;

Problem solved, you did not used the GC.

Your proposal also seems to require that all allocations are done with the GC (otherwise, how can things be "transferred" to the GC?). How can various destroyers know which allocator was used with each object? (One could add a pointer to the allocator to all class objects.)

Does this preclude allocating on the stack, using malloc, using custom allocators, etc.?

> If the catch is owned, then the ownership of the Exception is transferred to the catch block. It is then either transferred back to the runtime in case of rethrow, or consumed/destroyed depending on what the catch block is doing with it.

What happens if the:

   catch (owned Exception e)

is faced with an Exception that is not owned? Does it not catch it at all? If so, doesn't that imply that for practical purposes all thrown Exceptions need to be owned? Or should there be overloading of catch blocks:

   try { ... }
   catch (owned Exception e) { ... }
   catch (scope Exception e) { ... }
   catch (Exception e) { ... }

It not look enticing.

Reply via email to