In many languages invented since c that have errors as values, you can use something akin to a specialized monad to sequence things which may fail together.
For example, in rust you could use:
let res1 = w.Write(...)?;
let res2 = w.Write(res1)?;
In haskell, you can use do notation or monad binding to do a similar thing.
Of course C doesn't have a good type system that allows this sort of thing; it was created before such type systems were well known.
I would expect any modern language to at least recognize that there are good ways to sequence and compose types.
And so it's clear to others, this probably the worst possible way for a language to go about implementing error handling (maybe aside from just not having any mechanism outright and terminating).
But alas, those are the choices that the Go language made.
TheDong|7 years ago
For example, in rust you could use:
In haskell, you can use do notation or monad binding to do a similar thing.Of course C doesn't have a good type system that allows this sort of thing; it was created before such type systems were well known.
I would expect any modern language to at least recognize that there are good ways to sequence and compose types.
nkozyra|7 years ago
if err != nil {}
You get used to that pretty quickly in Go, but it still looks messy to a lot of people.
dymk|7 years ago
But alas, those are the choices that the Go language made.
bouncycastle|7 years ago