On Tuesday, 24 February 2015 at 23:02:14 UTC, ponce wrote:
One (big) problem about error code is that they do get ignored,
much too often. It's like manual memory management, everyone
think they can do it without errors, but mostly everyone fail
at it (me too, and you too).
Explicit return values for errors is usually annoying, yes, but
it is possible to have a language construct that isn't ignorable.
That means you have to explicitly state that you are ignoring the
error. E.g.
open_file("file2")?.write("stuff") // only write if file is
ready
open_file("file1")?.write("ffuts") // only write if file is
ready
if ( error ) log_error() // log if some files were not ready
or:
f = open_file(…)
g = open_file(…)
h = open_file(…)
if( error(f,g,h) ) log_error
Also with async programming, futures/promises, the errors will be
delayed, so you might be better off having them as part of the
object.