News for hackers. Stuff that matters.
Re:Push ifs up and fors down by hedora on Wednesday November 15, 2023 @10:06PM (#38285452)
Even better, if you're using a language with pattern matching (rust, any ML, haskell), just put it in a single match with the happy case on top, and the error cases below.

To do this, you need to encode the distinction between happy and sad path in your types. That's good for all sorts of other reasons, so it's not really a drawback.

Re:Push ifs up and fors down by KineticLensman on Thursday November 16, 2023 @05:19AM (#38287771)
Yes, pattern matching really helps with clarity, especially when there are multiple happy paths, like in a parser