3 ms·
I have the same feeling about boost's optional. It's a bandage on a wooden leg.
by toolslive 11y ago
I have the same feeling about boost's optional. It's a bandage on a wooden leg.
- stinos 11y agoBut is it really? Maybe I'm missing the point but it is a nice way to express that a function may or may not calculate something, no? At least it seems way better than returning bare pointers or pasing an argument by reference+returning bool, or returning a unique_ptr, or ...
- toolslive 11y agoIf you come from ML or Haskell and start using boost or Java's option, you actually feel ripped off. Some people claim it's a sort of documentation denoting 'intent', but I don't want documentation. I don't want options to infect the whole codebase, I just want to pattern match once and extract the value, and never have to check again for None or null. The problem in Java is the type system has references. X static use_it(X x){ ....} really has a signature something like this: use_it : X ref -> X ref no little library is going to fix that.
- gurkendoktor 11y agostd::string always is a value, boost::optional<std::string> isn't (similar to std::string, just a lot safer). The problem is that Java only has boost::optional<std::string>, which can be null, empty or a value.
- gurkendoktor 11y ago(Hacker News obviously wasn't made for writing about C pointers—the places where the text turns into italics and back where supposed to be asterisks.)