3 ms·
My proposal: add “→”, with the following semantics: Instead of having programmers slog through an if statement: if err != nil { return err } Allow th
by riwsky 4y ago
My proposal: add “→”, with the following semantics:
Instead of having programmers slog through an if statement:
if err != nil {
return err
}
Allow them to instead write [the superior]:
err != nil → {
return err
}
PROS:
* composes well with go’s existing “errors as values” philosophy
* matches →‘s usage in formal logic to signify implication
* a whopping 50% less verbose than “if”
CONS:
* to make it backwards compatible, we’d need to also add “←”
- kaba0 4y agoThis seems like rust’s return types with `if let`, which is a general concept instead of hard coding it for one specific use case.