Hacker News new | past | comments | ask | show | jobs | submit login

> 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




What 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/

[2]: https://github.com/vlang/v/blob/master/doc/docs.md#optionres...

[3]: https://github.com/vlang/v/blob/master/doc/docs.md#sum-types

[4]: https://github.com/vlang/v/blob/master/doc/docs.md#returning...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: