3 ms·
> I agree that Go should really have an analogue to Rust's `?`, but you can't really do that in a sane way without sum types to represent your conditions. The v
by dfawcus 2y ago
> I agree that Go should really have an analogue to Rust's `?`, but you can't really do that in a sane way without sum types to represent your conditions. The very multiple-return style error propagation makes it impractical to do.
There is always the Odin style 'or_return' operator, which is defined for a similar situation.
https://odin-lang.org/docs/overview/#or_return-operator https://odin-lang.org/docs/overview/#or_return-operator
- baranul 2y agoWhat is quite interesting (after looking at their documentation), is that V lang[1] has all that is mentioned: `?`[2], `or`[2], sum types[3], and can return multiple values[4]. [1]: https://vlang.io/ https://vlang.io/ [2]: https://github.com/vlang/v/blob/master/doc/docs.md#optionresult-types-and-error-handling https://github.com/vlang/v/blob/master/doc/docs.md#optionres... [3]: https://github.com/vlang/v/blob/master/doc/docs.md#sum-types https://github.com/vlang/v/blob/master/doc/docs.md#sum-types [4]: https://github.com/vlang/v/blob/master/doc/docs.md#returning-multiple-values https://github.com/vlang/v/blob/master/doc/docs.md#returning...