4 ms·
C++ is not always able to detect common parameter errors, especially for things like implicit conversions of numbers. Arguably Python’s option of keyword argum
by makecheck 9y ago
C++ is not always able to detect common parameter errors, especially for things like implicit conversions of numbers. Arguably Python’s option of keyword arguments make certain classes of parameter errors go away, too.
Several years ago I remember someone who (perhaps unwisely) wrote a C++ function with many floating-point values as parameters and a single default "bool". At some point the function was extended to have another float. The compiler did not catch calling code that failed to add an extra float; it simply allowed the formerly-flag arguments to be assigned to the new float argument instead. In fact, implicit conversion of parameters is such a common C++ problem that I occasionally define wrapping types for the sole purpose of being parameter types: then the compiler has to trip over them when they are used incorrectly and callers have to do some kind of explicit action to indicate what their values really are.
- mathw 9y agoThose implicit conversion rules (largely inherited from C) are one of the bits of C++ that bit me the most when I was a primary C++ dev.