[OT] - C++ exceptions are becoming more and more problematic
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Feb 24 22:09:20 UTC 2022
On Thu, Feb 24, 2022 at 08:34:03PM +0000, IGotD- via Digitalmars-d wrote:
[...]
> Exceptions are nice because they go under the hood and we can catch
> them ... if we want to.
Exactly, it makes APIs cleaner and code more maintainable when you don't
have to litter it with error-handling paraphrenalia all over the place.
Just like how having a GC allows you to eliminate memory-management
paraphrenalia that pollutes, e.g., every C/C++ API. The resulting code
is cleaner, more readable/maintainable, and more easily composable.
[...]
> .unwrap hell á la Rust is something I want to avoid.
Yeah, that's a route I hope we would *not* take in our effort to replace
exceptions.
I've said this before, but I suspect Walter's problem with exceptions
isn't so much the concept of exceptions itself, but rather with the
current implementation, which we inherited from C++. There's got to be a
way of working with exception-like syntax and convenience without the
performance hit *and* without the proliferation of error-code handling
boilerplate.
T
--
Never wrestle a pig. You both get covered in mud, and the pig likes it.
More information about the Digitalmars-d
mailing list