Are there plans for docs to be updated? The 0.3 release notes claim:
> Option and Result are now separate types: ?Foo and !Foo respectively. Old code will continue working for 1 year and will result in a warning/hint.
Yet, doc/docs.md still states:
> V combines Option and Result into one type, so you don't need to decide which one to use.
Is there an up-to-date doc, or how does one find out more about these types? I found parts of the RFC overhauling the error handling [0] pretty bizarre, so I'm interested to see how the implementation turned out.
Combining them in general makes sense to me, at least to the extent of having an Optional<T> be an alias of Result<T, ()>.
There are some obvious cases where a none optional is separate from failure, like a hash map lookup or an element from an iterator. But I often also see optionals used to signal e.g. an unparseable string, where it would seem equally reasonable to return a Result or throw an error.
I’ve been writing a lot of Swift lately, and because it uses `throws` rather than a Result type, it’s made the often arbitrary choice of returning an optional value or raising an error more noticeable to me. Especially when using `async`, as pretty much everything declared `async` also throws, so if an Optional is actually what you want to return, you get some fairly gross boilerplate at the site of use:
guard let value = try await getValue() else { … }
This has turned into a bit of a ramble but my main point is that implementing Optional as a Result with void error type makes a lot of sense in my head.
> Option and Result are now separate types: ?Foo and !Foo respectively. Old code will continue working for 1 year and will result in a warning/hint.
Yet, doc/docs.md still states:
> V combines Option and Result into one type, so you don't need to decide which one to use.
Is there an up-to-date doc, or how does one find out more about these types? I found parts of the RFC overhauling the error handling [0] pretty bizarre, so I'm interested to see how the implementation turned out.
[0]: https://github.com/vlang/rfcs/pull/7
edit: linked to the wrong RFC initially.