4 ms·
there has to be a better way. the error code checking sounds a little too manual for a modern language imho.
by smrtinsert 13y ago
there has to be a better way. the error code checking sounds a little too manual for a modern language imho.
- garfij 13y agoIn what ways is testing an error code with an if statement more manual than catching an exception with a try/catch?
- steveklabnik 13y agoThey didn't actually imply that try/catch was a solution, they just said there has to be a better way. For example, Option types...
- waffle_ss 13y agoThere is a better way. Check out how Erlang embraces failure with its "let it crash" philosophy, and considers trying to handle every error condition manually ("defensive programming") an anti-pattern. Read the "Error handling philosophy" section of Joe Armstrong's thesis[1] if you want to learn more. [1]: http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf http://www.sics.se/~joe/thesis/armstrong_thesis_2003.pdf
- mamcx 13y agoHow apply this to a language like python?
- mamcx 13y agoI wonder if embrace the unix stdin/stdout is the solution. I'm toying about a new languagte where each function have IN/OUT/ERR channels. So, is possible to do: result | err = open('file) This consume the ERR channel, however, if is not: result = open('file') it "trow". Inside the open, any raise is like a return for the ERR channel. This combined with RAII & scope like in D: http://dlang.org/exception-safe.html http://dlang.org/exception-safe.html