Comment

Comment by somefive

    "The decoupling between raising of the exception and handling it, that makes avoiding failures so easy in C++."
The point of exceptions, over C-style errors codes, is that you cant forget to handle errors.

    "When you create an instance of the class, constructor is called (which cannot fail) and then you explicitly call init function (which can fail)."
That's an anti-pattern. Initialization should happen in the constructor, not be separated into another step. (Look up RAII)

If you cant make exceptions work for you (for instance if you are making drivers or embedded programs), I have good news for you. Lightweight exceptions are being worked on and will most likely end up in the standard in 2023.

http://open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0709r0....

parent somefive 8 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton