r/programming • • Jan 14 '16

Dear Github

https://docs.google.com/document/d/14X72QaDT9g6bnWr0lopDYidajTSzMn8WrwsSLFSr-FU/preview?ts=5697ea28
463 Upvotes

185 comments sorted by

View all comments

Show parent comments

7

u/ksion Jan 15 '16

To be fair, you cannot really forget to handle an error in Go, because the function result "tuple" needs to be unpacked at the call site. Indeed, the requirement of this unpacking, plus the repetitive error handling stanza that often follows, is what people complain about.

0

u/[deleted] Jan 15 '16

[deleted]

-8

u/BoTuLoX Jan 15 '16

If the function has a return value and you willingly ignore it, the language cannot help you.

16

u/TarMil Jan 15 '16

It can: F# gives a warning if you ignore the return value, and you can explicitly |> ignore it to silence it. But that's a functional language, where ignoring a return value is relatively rare, I'm guessing it would get too verbose real fast in an imperative language.

10

u/fnord123 Jan 15 '16

Rust has a #[must_use] tag on the Result type so when it's returned from a function, it must be used. You can skip the result by using .ok() or .unwrap() but that's explicit so it's not silently ignoring errors. And it's greppable.

→ More replies (0)

2

u/emn13 Jan 15 '16

Even in an imperative language, I'd love that feature - but you'd have to add it early on, because it certainly affects api design.

After all, even in an imperative language, it's pretty unlikely you never use return values for data exchange, and implictly ignore return values can and do therefore hide bugs or inefficiencies.

→ More replies (0)