Operator overloading, when to
-
David1987 wrote:
It's not the only mistake they made.
Your opinion.
David1987 wrote:
The C# creators disagreed with them.
Actually your opinion as well. The existence of the idiom in the language itself is not proof of your opinion. Now if you can provide a documented reference that states specifically that it was added because Java didn't have it (versus say because C++ does) then that would certainly be relevent. Relevent of their opinion though and nothing else.
No. You're just talking crap here. They didn't choose to leave operator overloading out, so they can't have seen it as a major problem. It doesn't matter whether they specifically added it because Java didn't have it - it matters that they didn't see it as a problem. Their disagreement doesn't have to be explicit to be disagreement.
-
Your own argument defeats yourself. C# is a general purpose language and so should be able to deal with it if some calculations are required. It would be pretty silly to have a language that can't calculate (XSTL?) But then, in a ray tracer the majority of the code isn't mathematics - just a lot of it. Building a ray tracer in mathematica or maple is kind of silly. Operators exist for built-in types, not allowing them on "everything else" makes the built-in types more special. In Java they are even more special and that sucks even more. It's not "nice" or "elegant" and it has bitten almost everyone who learned the language.
jschell wrote:
Third C# does not limit operator overloading in such a way to make it incompatible with the problems that one might experience from abusing the idiom. Just as with C++.
It is impossible to do so anyway. Just don't abuse it then. C# also does not limit method overloading and virtual methods and strings in such a way that you can't abuse them. Nor should it try to, you'd end up with a language that you'd have to fight at every turn to get something done. (like Haskell? and even haskell, for all its 'purity' has unsafePerformIO - and is not immune to string abuse, which is probably impossible to ban)
jschell wrote:
First I can provide a quote from Stroustrup that says that he specifically thinks that the operator overloading in streams is an excellent use.
Well of course, why else would he have done it that way. That doesn't mean that I'm going to agree with him though. << and >> should be used for bitwise shifts, any other use is abuse at least in my opinion, and I'm reasonably sure that a lot of people agree with that.
David1987 wrote:
Your own argument defeats yourself. C# is a general purpose language and so should be able to deal with it if some calculations are required.
I see no problem with creating a vector library in Java. So no it doesn't defeat my point. And a general purpose language is NOT intended to be able to solve all problems and is certainly NOT intended to solve all of them in an ideal way either.
David1987 wrote:
Operators exist for built-in types, not allowing them on "everything else" makes the built-in types more special. In Java they are even more special and that sucks even more. It's not "nice" or "elegant" and it has bitten almost everyone who learned the language.
I have seen a lot of code in a lot of languages. Some elegant some not. But nothing in that statement has anything to do with operator overloading.
David1987 wrote:
It is impossible to do so anyway. Just don't abuse it then. C# also does not limit method overloading and virtual methods and strings in such a way that you can't abuse them. Nor should it try to, you'd end up with a language that you'd have to fight at every turn to get something done. (like Haskell? and even haskell, for all its 'purity' has unsafePerformIO - and is not immune to string abuse, which is probably impossible to ban)
To make it specifically clear - I do not accept your analogy of strings/virtuals as equivalent to operator overloading. A better analogy would be inheritance which is abused a great deal. However eliminating inheritance does not leave one with an alternative. That isn't true for operator overloading.
-
No. You're just talking crap here. They didn't choose to leave operator overloading out, so they can't have seen it as a major problem. It doesn't matter whether they specifically added it because Java didn't have it - it matters that they didn't see it as a problem. Their disagreement doesn't have to be explicit to be disagreement.
You specifically said. "The C# creators disagreed with them." That suggests intent. 1. They looked at Java, it didn't have operator overloading and thus they added it because Java didn't have it. In this case they disagreed with the the designers of Java. 2. Conversely they could have looked at C++, saw that it had operator overloading and added it because of that. In this case they agreed with the designers of C++. 1 and 2 are not the same.
-
David1987 wrote:
Your own argument defeats yourself. C# is a general purpose language and so should be able to deal with it if some calculations are required.
I see no problem with creating a vector library in Java. So no it doesn't defeat my point. And a general purpose language is NOT intended to be able to solve all problems and is certainly NOT intended to solve all of them in an ideal way either.
David1987 wrote:
Operators exist for built-in types, not allowing them on "everything else" makes the built-in types more special. In Java they are even more special and that sucks even more. It's not "nice" or "elegant" and it has bitten almost everyone who learned the language.
I have seen a lot of code in a lot of languages. Some elegant some not. But nothing in that statement has anything to do with operator overloading.
David1987 wrote:
It is impossible to do so anyway. Just don't abuse it then. C# also does not limit method overloading and virtual methods and strings in such a way that you can't abuse them. Nor should it try to, you'd end up with a language that you'd have to fight at every turn to get something done. (like Haskell? and even haskell, for all its 'purity' has unsafePerformIO - and is not immune to string abuse, which is probably impossible to ban)
To make it specifically clear - I do not accept your analogy of strings/virtuals as equivalent to operator overloading. A better analogy would be inheritance which is abused a great deal. However eliminating inheritance does not leave one with an alternative. That isn't true for operator overloading.
-
You specifically said. "The C# creators disagreed with them." That suggests intent. 1. They looked at Java, it didn't have operator overloading and thus they added it because Java didn't have it. In this case they disagreed with the the designers of Java. 2. Conversely they could have looked at C++, saw that it had operator overloading and added it because of that. In this case they agreed with the designers of C++. 1 and 2 are not the same.
-
You specifically said. "The C# creators disagreed with them." That suggests intent. 1. They looked at Java, it didn't have operator overloading and thus they added it because Java didn't have it. In this case they disagreed with the the designers of Java. 2. Conversely they could have looked at C++, saw that it had operator overloading and added it because of that. In this case they agreed with the designers of C++. 1 and 2 are not the same.
-
Also in case you hadn't noticed, a post like that is the mark of a troll. There is no doubt about it. You are purposefully wasting my time with your intentional nonsense.
David1987 wrote:
Also in case you hadn't noticed, a post like that is the mark of a troll. There is no doubt about it. You are purposefully wasting my time with your intentional nonsense.
Because you said it, it must be so. Couldn't possibly be because I disagree with your opinion.
-
David1987 wrote:
Ok, then I accept none of your arguments and you are simply wrong. Case closed. Troll.
Pretty sure I said early on that you were expressing nothing but a personal opinion.