|
|
Disch wrote: |
---|
there's no way to detect that it happened from outside the class. |
Disch wrote: |
---|
Also, it does something other than what the user of the class intended. |
Disch wrote: |
---|
Silently faking a success is worse than failing. I would rather my code fail. |
Disch wrote: |
---|
I mean... how would you like it if a class like std::string did that? IE, instead of throwing an exception when it can't allocate more space, if it just didn't grow the string? That would be disasterous! |
@Disch: Use a pattern: if(Image foo ("someimage.png")) |
Logging. |
I modify the content of "someimage.png" and run the program. Oh no! I should throw an exception because this is surely not what the user intended. |
Then it is a context-dependent opinion. I don't want the player to be unable to play the game just because I forgot to include "someimage.png" in the patch. |
Out of memory: abort program. What could you do anyway? |
I do not design the standard C++ library. |
if(Image foo ("someimage.png")) |
I don't want the player to be unable to play the game just because I forgot to include "someimage.png" in the patch. |
I would argue that moving from a named variable is bad practice. |
|
|
load the appropriate inbuilt default asset for that asset type (e.g. pink-and-black checkerboard for missing texture) |
LB wrote: |
---|
I have yet to research the new C++11 multithreading classes, but from my understanding, this code blocks until it can continue. I don't understand how it can fail. |
if I am understanding you correctly, the main advantage of exceptions in C++ is that they can be thrown from constructors? |
makes exception-less C++ worthless |
Google would be better off with another language (and they made one). |
Disch wrote: |
---|
So... option #2... put the object in an error state. |
Disch wrote: |
---|
I'm talking about silent to the program. IE, the program can't react to it. |
Disch wrote: |
---|
I don't understand what you are saying here. |
Disch wrote: |
---|
Throwing an exception does not mean the player is unable to play the game. It means your program is being alerted that something went wrong. |
Disch wrote: |
---|
Switch to lower res resources. |
helios wrote: |
---|
Write a resource manager that checks at startup that all required resources are present |
MiiNipaa wrote: |
---|
Alternatives? Also I am still trying to imagine how to access unnamed function arguments. |
Lachlan Easton wrote: |
---|
I think it's worth pointing out that every successful game engine ever (possible exaggeration) does this. |
Cubbi wrote: |
---|
It's not the only reason to use them, but it is the killer feature that makes exception-less C++ worthless |
It is not possible to know what all required resources are. |
LB wrote: |
---|
Aside from memory allocation, why would I be throwing exceptions from ctors though? |
Cubbi wrote: |
---|
Besides environmental conditions, invalid values passed to constructor arguments can be unacceptable, as well as the values currently found in singletons/globals/Fortran commons that the constructor may need. |
Cubbi wrote: |
---|
That's called "wide contract", it's a whole different thread. |
So I can't play the game with MyFavoritePlugin just because someone forgot to include a sound for bunnies? |
Zereo wrote: |
---|
Though anyways my point of view on the original subject is that exceptions not only make error handling easier to write they also make it so it is harder for you to make mistakes. |
Zereo wrote: |
---|
because you have to propagate the errors by hand |
Zereo wrote: |
---|
So in short exceptions are much easier to read, faster then most error handling code, easier to maintain and they are universally known. |
From my point of view, exeptions make it easier to write code that requires error handling as well as easier to write code that can cause errors. They seem like an excuse to me. |
You are still thinking as if you are using exceptions, just without language-level support. Try thinking without exceptions. |
Yes, yes, yes, and yes. But that doesn't make them seem right to me. There are plenty of analogies I could make and screw up relating to ancient medicinal practices. So I'll leave you to guess what I hope is an obvious analogy. Exceptions are good at solving the problem they were meant to solve. But where did that problem come from? What caused us to need to invent exception handling? That is a greater concern for me. |
Zereo wrote: |
---|
I am not sure what you mean by exceptions making it easier to write code that requires error handling. |
Zereo wrote: |
---|
After reading over some of your previous posts it seems you seem to believe that it is possible to write code that doesn't have the probability for errors in it. This just isn't realistic in my opinion. |
Zereo wrote: |
---|
I am not really sure what you mean here. If a error happens deep inside the callstack and can't be handled by that current system it will need to be propagated up the call stack to a system that can. |
Zereo wrote: |
---|
Again I am not really sure what you mean here. |
They should be abstracted away and dealt with internally. |
You hire a company to build a house for you somewhere. One day the company calls and says it's your responsibility to repair the roof that caved-in from heavy snowfall. "Sorry, we don't offer repair services." |