Am Thu, 08 Sep 2016 07:52:58 +0000 schrieb Ethan Watson <goober...@gmail.com>:
> On Wednesday, 7 September 2016 at 21:05:32 UTC, Walter Bright > wrote: > > 5. In my not-so-humble opinion, construction should never fail > > and all constructors should be nothrow, but I understand that > > is a minority viewpoint > > 100% agree there. I can't think of any class in our C++ codebase > that fails construction, and it's a pretty common rule in the > games industry to not assert/throw exceptions during construction. > > Of course, with Binderoo being open sourced, I can't guarantee > any of my end users will be just as disciplined. So when you have an object that reads state from a file, you first construct it and then call a member function "loadFromFile()" that may throw? For argument's sake let's take a *.bmp class. That one would not have a constructor with a filename? Or do you have such constructors and I/O exceptions are just logged and swallowed? I'd like to understand how it would behave, since obviously both you and Walter have written large software products and personally I prefer to attempt construction and rollback on errors until I'm back in the state where the user initiated the action. What is the benefit? Well, one benefit is that you are forced to write error concealment code and make the best out of partially broken input. Others? Out-of-memory and invalid arguments would be other examples of exceptions, but I guess the Errors thrown from asserts don't count as exceptions in the regular sense, since by definition they are non-recoverable. -- Marco