3 ms·
I really liked how Icon handles function success/failure separately from return values. It seems very close to Go's error handling conventions, but with a littl
by cpeterso 9y ago
I really liked how Icon handles function success/failure separately from return values. It seems very close to Go's error handling conventions, but with a little more magic. Wikipedia gives the following Icon example code:
if a := read() then write(a)
which would translate into something like the following Go code:
a, err := read()
if err == nil {
write(a)
}
- oldandtired 9y agoSimplify this to write(a := read()) where write will not be executed if read fails, nor will a have any value assigned to it. Failure is an option and not an error. So to copy standard input to standard output, we do every write(read()) At the end of file, the read fails, the write fails and then the every fails and on you go.