nothrow by default

Ola Fosheim Grøstad ola.fosheim.grostad at
Sun Jan 5 21:37:04 UTC 2020

On Sunday, 5 January 2020 at 21:06:00 UTC, Johannes Pfau wrote:
> As far as I know, starting from C++11 std::error_code can be 
> extended and has been used in newer updates to the C++ standard 
> library instead of exceptions. (e.g. there is now a future 
> error category). See https:// 
> std::expected / boost outcome proposals are also related. There 
> certainly is a trend away from exception to error-code like 
> systems. But I have to admit, I don't know much about C++, so 
> maybe those are bad / non- representative examples.

Oh! I see where you are coming from. So, in D you have the 
problem that large sections of the standard library cannot be 
used with out the GC. In C++ you have a similar problem with not 
being able to use most of the standard library (safely) if you 
turn off exceptions. So they have both tried to make the code gen 
for exception code better, but I believe there also is an effort 
to make more of the standard library usable for those who choose 
to turn off exceptions.

> That's probably true. Still, you can do a exception system with 
> the same user facing API but without backtracing. So you get 
> rid of unwind tables and the backtrace support code making the 
> failure case faster while reducing the performance of the 
> succes case. In that case the only question is whether the 
> performance difference is important for some applications.
> Of course, ideally which backend implementation is used could 
> be an implementation detail.

There are absolutely many paths to new (or old) interesting error 
handling/resource management mechanisms. E.g. some research 
language for system programming have used arenas with compiler 
backing and other have explored other alternatives.

But D has to figure out how to relate to C++. Doing the opposite 
of C++ just on the syntax level (throw/nothrow/noexcept), does 
not make much sense if D is to attract C++ developers. It has to 
be substantially better to have an impact, like you suggest.

More information about the Digitalmars-d mailing list