4 ms·
This is not a great example because a string conversion by nature requires error-checking and should not be a simple return-by-value. A string can contain anyt
by makecheck 6y ago
This is not a great example because a string conversion by nature requires error-checking and should not be a simple return-by-value.
A string can contain anything and certainly not conform to its expected type. With a normal “error” return code (and overload-friendly type-specific parameter to find the converted value when successful), I can handle any type without magic and can also check errors. Futhermore, the return-parameter approach encourages me to actually think about errors instead of ignoring them (their function example of f(from_string(...), from_string(...)) is terrible).