logoalt Hacker News

fwiplast Saturday at 6:47 PM1 replyview on HN

I share your distaste for arbitrarily renaming concepts. However, I think if you only have one of the two in the language, Optional is the clearer name.

A result is already the informal name of the outcome or return value of every regular operation or function call, whereas an Optional is clearly not a regular thing.

I also think, from a pragmatic systems-design point of view, it might make sense to only support the Either/Result pattern. It's not too much boilerplate to add a `faultdef KeyNotInMap`, and then it's clear to the consumer why a real answer was not returned.


Replies

loeglast Saturday at 7:47 PM

It's not just arbitrary renaming (Rust Result vs C++ Expected is fine) -- it's choosing a conflicting name for an extremely common abstract data type. If they wanted to call it "Elephant," great, but Optional is a well-known concept and Result/Expected isn't the same thing.

(I don't really object to the idea of skipping a real Optional<T> type in a language in favor of just Result<T, ()>.)

show 1 reply