Possibility of adopting Rust's Error Handling?

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Mar 31 22:00:17 UTC 2022


On Thu, Mar 31, 2022 at 09:46:53PM +0000, IGotD- via Digitalmars-d wrote:
[...]
> I think that exceptions are superior to return values for the
> programmer.

+1.


> However there are performance bottlenecks. Instead D should focus on
> how to improve its exceptions, like looking if value exceptions could
> be beneficial, unnecessary locking, if they can be stored temporarily
> on stack instead of heap, how they can better work with the optimizer,
> include TypeInfo in better C so that exceptions work there.

AIUI, D used to have its own implementation of exceptions that was more
performant than libunwind.  Sadly, that got junked in the name of C++
compatibility, so now we're stuck with libunwind along with all of its
downfalls.

In theory, if we're willing to accept ABI changes, we could replace the
current libunwind-based implementation with a register-based status to
indicate when an exception is thrown, and emit explicit branches for
that. Then it would be the equivalent of error-code-based handling,
except without the code uglification and the type constraints.


T

-- 
Computers are like a jungle: they have monitor lizards, rams, mice, c-moss, binary trees... and bugs.


More information about the Digitalmars-d mailing list