|
|
|
|
|
by enriquto
1830 days ago
|
|
> Every OOP language has different behaviour for different input types Yeah. And I find OOP horrific. > How would you feel about having to write `sqrt_int32(x)`, `sqrt_int64(x)`, `sqrt_float64(x)`, What kind of savage wants the square root of an integer? I'd prefer if the language only had a single number type (maybe configurable at once by an external option) and a single sqrt function. But if you talk about the general problem of naming functions differently according to their types, I feel that it's perfectly OK. A tiny price that I'm eager to pay for the large benefit of being able to identify which function is called just by looking at its name (and not at the---possibly yet undetermined---types of its arguments). |
|
Your function may be written for numeric, and you use your favorite kind exclusively.
Now person B from this thread comes along, using both ints and floats. Well guess what, your package still works seamlessly. And where it doesn't, it must be due to a particularity that you yourself don't care about. In any case, the function can then be extended without namespace issues. In other languages, one would have to rewrite your package since you are using an obscure numeric type which others don't agree with.
Consider for example how people have used solvers for differential equations with entirely new datatypes, simply because the compatibility comes for free.
I think it's really neat!
I think it's great!