4 ms·
> Not allowing the addition of floats and ints together is less of a fundamental issue, but it also helps quite a few problems. Needing to use +. to add two fl
by runeks 9y ago
> Not allowing the addition of floats and ints together is less of a fundamental issue, but it also helps quite a few problems.
Needing to use +. to add two floats seems odd to me as well, and I believe this is what OP was pointing out. I would agree with you that adding and int to a float should require conversion of one of the arguments, but I see no need for a separate + operator for floats and ints.
- kbenson 9y ago> I would agree with you that adding and int to a float should require conversion of one of the arguments, but I see no need for a separate + operator for floats and ints. Yes, what I was trying to express is that in a typed language with many types, choosing a few types and using operators to signify what you are doing is an odd choice, especially if you implement it for some types but not others. I understand the want of the language designers to protect people from these mistakes, I just think they chose an oddly inconsistent way of of doing so. The logical conclusion of different operators for different types is many more operators than shown here, so that leaves the language with these special cases. Special cases cause confusion.