top | item 43489389

(no title)

elvlysh | 11 months ago

So you would prefer to write match result => error instead of if err != nil? Excuse me for not being convinced that this isn't just fussing over syntax.

discuss

order

valenterry|11 months ago

If a language supports Result types, that usually means it also comes with some kind of syntax to use it. Check out some Rust code (or Haskell, Scala, F#, ...) and you will find that in those languages you barely match on the result because you don't have to. Whereas you have to do "if err != nil" in golang all the time.

stouset|11 months ago

It isn’t just fussing over syntax, but that would require you actually being curious enough to learn why instead of needing to dismiss people’s valid critiques of out hand.

tubthumper8|11 months ago

It's not just syntax, a sum type forces checking for the error whereas a product type does not, so it's a semantic distinction too