3 ms·
Now imagine you are using type inference using `auto` and you are refactoring some functions from returning `bool` to `optional<bool>`. Good luck with that.
by hoppelhase 8y ago
Now imagine you are using type inference using `auto` and you are refactoring some functions from returning `bool` to `optional<bool>`.
Good luck with that.
- geezerjay 8y ago> returning `bool` to `optional<bool>`. In that case you need to pay attention to what you're doing. Semantically you'd be altering your code to convert a function that always returns a value into a function that maybe won't return it. How do you expect to replace a type with a wrapper that maybe won't wrap that type and still assume you won't need to check if a return value exists? That would be like replacing a reference with a pointer and then forgetting to check if the pointer is null. Making this mistake has nothing to do with luck and has everything to do with incompetence, and no language specs saves you from that.
- hoppelhase 8y agoOf course you have to check if the value exists. But you did not get my point. If the optional wouldn't be an implicit boolean, you'd see compile errors on the locations you forgot to change (even if you use type inference).