3 ms·
What seems weird here? Iterating or mapping over Options is pretty normal in functional languages.
by mkehrt 1y ago
What seems weird here? Iterating or mapping over Options is pretty normal in functional languages.
- deleted 1y ago[deleted]
- lo_zamoyski 1y agoWell, you can map over options/maybes. For-loop style iteration over an option does seem a little strange IMO, first, because syntactically it looks like overkill, and second (and more importantly), because map evals to a value, while `for` does not. But I suppose in C++, given the centrality of looping constructs, this is what you would do to accommodate option.
- halayli 1y agoYou're comparing apples to oranges. In pure functional languages, Option is a fundamental type. It's a concept introduced very early on when learning FP. Historically it had the same behavior and definition. Trying to gaslight ppl to question their reasonable reaction of std::optional transitioning from its previous behavior to an Option like behavior when no other type in C++ behaves as such is disingenuous. Of course it is weird in the C++ context, but is it a step in the right direction? absolutely!