3 ms·
I couldn't agree more! When I first used Qt, I wondered how such a large framework could get along without exceptions. After writing some non-trivial Qt progra
by vog 10y ago
I couldn't agree more!
When I first used Qt, I wondered how such a large framework could get along without exceptions. After writing some non-trivial Qt programs, I still noticed that there is really no need for exceptions, except when interfacing non-Qt libraries, where I simply caught and handled the exceptions in a small wrapper.
Finally, I got it: Qt uses the Null-Object pattern (not to be confused with Null values!) consistently, which is really in almost all cases the more elegant solution:
https://en.wikipedia.org/wiki/Null_Object_pattern https://en.wikipedia.org/wiki/Null_Object_pattern
- blub 10y agoNull object is not bad, but std::optional has clearer semantics and is probably safer. This is probably the only sane alternative to exceptions - optional types and result<T, E> types.