[OT] - C++ exceptions are becoming more and more problematic
Paul Backus
snarwin at gmail.com
Thu Mar 3 15:35:03 UTC 2022
On Thursday, 3 March 2022 at 12:05:11 UTC, Atila Neves wrote:
> On Friday, 25 February 2022 at 00:30:49 UTC, H. S. Teoh wrote:
>>
>> Go, Zig, Rust, and Odin all require explicit checking for
>> error returns.
>
> Nope:
> http://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/reference/expressions/operator-expr.html#the-question-mark-operator
>
> Years ago, I justified my preference for exceptions because the
> rest of the call stack didn't have to be cluttered with
> "rethrowing". Having to pattern match is better, but still a
> pain. The macro solution they went with is the only one I know
> of that is as easy to use as exceptions without the associated
> baggage.
Swift has similar syntax sugar with its "try" keyword:
https://docs.swift.org/swift-book/LanguageGuide/ErrorHandling.html
And of course there are also more general-purpose language
features like Haskell's "do" notation [1] and Scala's "for"
comprehensions [2] that handle this as a special case.
[1] https://en.m.wikibooks.org/wiki/Haskell/do_notation
[2] https://docs.scala-lang.org/tour/for-comprehensions.html
More information about the Digitalmars-d
mailing list