News for hackers. Stuff that matters.
Re:The Cost of Exception Handling by chrisseaton on Saturday November 12, 2022 @07:43AM (#33572510)
> constructors don’t allow returning an error because C++ has exceptions

Didn't constructors (1979) come before exceptions (1986)? So no that's not the case.

Re:The Cost of Exception Handling by masklinn on Saturday November 12, 2022 @08:01AM (#33572628)
Yes, I didn't originally know that (I thought constructors and exceptions would have been co-implemented and didn't consider that faillible ctors would have been outright impossible for a decade), and found out after pjc50's reply: https://news.ycombinator.com/item?id=33572348
Re:The Cost of Exception Handling by chrisseaton on Saturday November 12, 2022 @09:45AM (#33573527)
People used to use a flag in objects to say 'invalid because constructor failed', or make the constructor infallible, and have a separated initialise method which could return an error code.