![]() | This ![]() It is of interest to the following WikiProjects: | ||||||||||||||||||||||||||||||||||||||||
|
|
Doesn't overloading usually refer to the static resolution of a call? For instance, + on int vs String in Java is resolved statically. A dynamic analog of overloading is something like a type-case or virtual methods. So I think this article should focus on the static case, which means that some of the examples, like LISP, do not feature overloading, because they are statically untyped. —Preceding unsigned comment added by 12.198.139.122 ( talk) 01:57, 6 February 2008 (UTC)
I removed this text:
Because I couldn't decipher what the original author was trying to express. If someone can clarify the intent of this passage and wants to put the content back into the article, please do so. Neilc 02:26, 11 Aug 2004 (UTC)
This doesn't make sense to me. How is it more than aesthetic? Is there other difference if you just write the invocation? I think the point is there might be a difference between function call semantics and operator semantics (such as a + b might choose between a.add and b.add)
By the way, you could add Lisp to the language classification :-)
What is meant by "declaring new operators"? 62.194.114.150 10:20, 28 Nov 2004 (UTC)
The criticism counts for all language features, so it is a red herring, imho.
Example:
a.addToList(b); // this function call sends an e-mail to Bill Gates
This is also an example of giving something a bad name (or bad semantics). The criticism is thus irrelevant. Wouter Lievens 10:48, 6 Mar 2005 (UTC)
It would be interesting to identify the first language to introduce operator overloading. Anyone know if any language before ALGOL 68 (1968) implemented it?
Rwendland 02:05, 6 Apr 2005 (UTC)
I've removed the "gutter talk" section, which (if you can't be bothered to check History) was about how what absolutely everyone calls "operator overloading" should really be called "operator overriding" unless a class exports more than one operator. Given that this is not a common criticism, nor is it supported by actual usage, I don't really think it's encyclopaedic content. (It was also of disputable accuracy.) Haeleth 14:49, September 6, 2005 (UTC)
In lisp, (+ 3 5) adds 3 & 5. Lisp uses the same syntax for functions: (funcname arg1 arg2) etc. Because of this, defining new operators in lisp is as easy as defining a new function. Overriding an operator is the same as defining a new function. Because of this, I changed lisp's position in the chart to indicate that operators are overloadable and new operators are definable.-- Dasunt 23:27, 3 March 2006 (UTC)
How is it that Ruby permits new operators to be defined? It seems to me that only existing operators that are part of the syntax can be defined as methods in Ruby. If that's not what that axis of the chart means, perhaps it should be clarified.
The ISO/IEC 2382 Standard Vocabularies for IT define an operator as a symbol that identifies or represents an operation. The definition does not limit symbols to single characters. Thus '+', 'add', 'first', 'next' could all be operators.
It is in fact the symbol that is overloaded through reuse. While, hopefully, the operations have similar semantics, the operations are in fact different.
A more accurate statement would be: "Operators are not limited to single characters." As it is, this article appears to contradict a fundamental computing definition and to confuse a symbol with what it represents.
The article lacks citations for verifiability and runs the risk of violating No Original Research or No Point of View.
Bob Badour 15:22, 29 June 2006 (UTC)
are there any known languages that support expression reduction (outside of the compiler)? —The preceding unsigned comment was added by 80.129.243.120 ( talk) 23:45, 17 January 2007 (UTC).
Java allows method overloading, hence it should be moved to another part of the graph. -- indil 08:48, 11 April 2007 (UTC)
Java allows only method overloading, that is different to *operator* overloading. 78.86.131.114 ( talk) 18:24, 13 August 2008 (UTC)
Which properties decide about the classification as operator. IMHO there are some points:
There are several notations which do not count as operators:
In the article several me too languages claim to have operators (IMHO they don't). Such languages should be mentioned in other articles but not here.
When there is no clear distinction about what counts as operator some information like the table about user definable / overloadable operators make not really sense. Only a few languages use real operators and allow user definable new operator symbols with priority and associativity. Because of the many me too languages this information is not clearly visible. Georg Peter 07:17, 30 October 2007 (UTC)
We have a bad example; adding two dates doesn't make sense, just as adding two pointers doesn't. We should change it into adding two durations of time, or two lengths, etc. — Musiphil ( talk) 19:07, 18 March 2009 (UTC)
Adding dates or pointers makes perfect sense for some applications. My concern is more practical in nature.
I would make the changes myself if I understood operator overloading and classes, but I never needed to use them in my work. In some ways that makes me the perfect audience but I cannot figure out the examples because:
1 I never used operator overloading and the concept is alien to me, as is classes
2 the examples do not have a specification explaining in plain language exactly what they are supposed to be doing to which nor are the special data types defined
3 the examples lack line-by-line comments exactly what each line is accomplishing
4 the code is not 'self-documenting' directly from the syntax, especially in the third example which I cannot even make out what its intent is let alone what it is doing
I think we all get the idea of operator overloading being subtle and confusing due to syntax, but that is not what is making this code difficult to understand nor is it pointing out to me why I should care.
Could you please add some declaration of data type and plain language pecification/description of the intended input, operation, and output of each of the three examples? Lacking that, how about line-by-line comments and a general description of what the third cryptic example does?
Then, how about pointing out specifically what is important about the operator overloading, with respect to the second and third examples?
Specifically, I fail to see what the point is for using a 'hidden' variable in the second example. I consider it poor coding style to use global variables without a good reason and in this case it only seems to be justifying the need for a class instead of a simple overload.
What about the global variable justifies the need for a class? Is it the lack of a lhs operand for a typically binary operator? If so, can we have sample instantiation because otherwise the implication is that it uses the same instantiation as the first example? Please state it clearly because it still has me baffled, like I said I never used classes, I did not need object oriented code. I would need to understand everything about classes and operator overloading already to understand the example and in that case what is the point of the encyclopedia?
In the third example I do not even know what it is for. I see no connection between it and the prior two examples, nor is there an instantiation or declaration of data type or anything, nor do I see that it even accomplishes anything since it seems to set everything to zeros. What are its operands? It seems like a ghost that returns no output at all.
Maybe too you could mention some practical implications of the chosen syntax for the overload and alternative coding to mitigate, like what I had to be concerned with such as for example (maybe not my specific concerns for these operator overload samples but similar in character to):
1 potential surprise pointer overflows from improper boundary conditions, and how to prevent this without relying on the compiler to catch it for you, letting J-bird Hacker Jones hijack your browser with data execution and clean out your bank account
2 unexpected processor or memory or stream overhead while executing the code due to practical hardware limitations on bandwidth, flushing the cache for unnecessary jump instruction, multiplying by 2 instead of left shifting, etc.
3 automatic compiler error-checking overhead that might get wrapped around the assembly language, that either mitigates or causes such non-transparent issues, and how to avoid the need for relying on the compiler to clean up sloppy code for you
4 'if' statements instead of modulo operators makes the code longer and more confusing since no one would ever code this way unless processor bandwidth or some other practical hardware constraint demanded it. Can we have examples that make sense mathematically and functionally, so that we can concentrate on the issue of operator overloading?
C syntax is confusing enough without leaving people that should be able to read this encyclopedia entry with ease scratching our heads in puzzlement. Please? thx —Preceding unsigned comment added by 75.79.69.67 ( talk) 13:51, 21 January 2010 (UTC)
Is this really an either/or situation? Are there no programming languages which allow both overloading existing operators, and defining new ones? After all these years I finally ran into a situation where having both features might be desirable in limited cases. Since my available tools are already pretty much set in stone, this is pretty much just an academic question, but I'm still interested. — Preceding unsigned comment added by 85.156.251.154 ( talk) 21:37, 31 October 2011 (UTC)
mod 5 4
is the same as 5 `mod` 4
and 1 + 2
is the same as (+) 1 2
).
strcat (
talk)
12:05, 2 November 2011 (UTC)
The phrase "claimed to be useful" is not NPOV and uses weasel words. I will remove it. Dpsanders ( talk) 05:06, 19 August 2013 (UTC)
Is there a chance that someone can take a step further back in the discussion and try to explain this to a more novice programmer? I am one such programmer (FORTRAN off & on for many years, Pascal, BASIC) but I have no idea what the author is saying. Operator Overloading remains a mystery to me after reading the article.
Thanks for considering — Preceding unsigned comment added by Mark B 64151 ( talk • contribs) 00:17, 4 December 2014 (UTC)
This article lists Smalltalk as one of the languages that allows operator overloading, but I found a textbook on Smalltalk that seems to contradict this. Methods and operators in Smalltalk can be overridden, but I'm not sure if they can be overloaded. Jarble ( talk) 17:34, 9 July 2020 (UTC)
![]() | This ![]() It is of interest to the following WikiProjects: | ||||||||||||||||||||||||||||||||||||||||
|
|
Doesn't overloading usually refer to the static resolution of a call? For instance, + on int vs String in Java is resolved statically. A dynamic analog of overloading is something like a type-case or virtual methods. So I think this article should focus on the static case, which means that some of the examples, like LISP, do not feature overloading, because they are statically untyped. —Preceding unsigned comment added by 12.198.139.122 ( talk) 01:57, 6 February 2008 (UTC)
I removed this text:
Because I couldn't decipher what the original author was trying to express. If someone can clarify the intent of this passage and wants to put the content back into the article, please do so. Neilc 02:26, 11 Aug 2004 (UTC)
This doesn't make sense to me. How is it more than aesthetic? Is there other difference if you just write the invocation? I think the point is there might be a difference between function call semantics and operator semantics (such as a + b might choose between a.add and b.add)
By the way, you could add Lisp to the language classification :-)
What is meant by "declaring new operators"? 62.194.114.150 10:20, 28 Nov 2004 (UTC)
The criticism counts for all language features, so it is a red herring, imho.
Example:
a.addToList(b); // this function call sends an e-mail to Bill Gates
This is also an example of giving something a bad name (or bad semantics). The criticism is thus irrelevant. Wouter Lievens 10:48, 6 Mar 2005 (UTC)
It would be interesting to identify the first language to introduce operator overloading. Anyone know if any language before ALGOL 68 (1968) implemented it?
Rwendland 02:05, 6 Apr 2005 (UTC)
I've removed the "gutter talk" section, which (if you can't be bothered to check History) was about how what absolutely everyone calls "operator overloading" should really be called "operator overriding" unless a class exports more than one operator. Given that this is not a common criticism, nor is it supported by actual usage, I don't really think it's encyclopaedic content. (It was also of disputable accuracy.) Haeleth 14:49, September 6, 2005 (UTC)
In lisp, (+ 3 5) adds 3 & 5. Lisp uses the same syntax for functions: (funcname arg1 arg2) etc. Because of this, defining new operators in lisp is as easy as defining a new function. Overriding an operator is the same as defining a new function. Because of this, I changed lisp's position in the chart to indicate that operators are overloadable and new operators are definable.-- Dasunt 23:27, 3 March 2006 (UTC)
How is it that Ruby permits new operators to be defined? It seems to me that only existing operators that are part of the syntax can be defined as methods in Ruby. If that's not what that axis of the chart means, perhaps it should be clarified.
The ISO/IEC 2382 Standard Vocabularies for IT define an operator as a symbol that identifies or represents an operation. The definition does not limit symbols to single characters. Thus '+', 'add', 'first', 'next' could all be operators.
It is in fact the symbol that is overloaded through reuse. While, hopefully, the operations have similar semantics, the operations are in fact different.
A more accurate statement would be: "Operators are not limited to single characters." As it is, this article appears to contradict a fundamental computing definition and to confuse a symbol with what it represents.
The article lacks citations for verifiability and runs the risk of violating No Original Research or No Point of View.
Bob Badour 15:22, 29 June 2006 (UTC)
are there any known languages that support expression reduction (outside of the compiler)? —The preceding unsigned comment was added by 80.129.243.120 ( talk) 23:45, 17 January 2007 (UTC).
Java allows method overloading, hence it should be moved to another part of the graph. -- indil 08:48, 11 April 2007 (UTC)
Java allows only method overloading, that is different to *operator* overloading. 78.86.131.114 ( talk) 18:24, 13 August 2008 (UTC)
Which properties decide about the classification as operator. IMHO there are some points:
There are several notations which do not count as operators:
In the article several me too languages claim to have operators (IMHO they don't). Such languages should be mentioned in other articles but not here.
When there is no clear distinction about what counts as operator some information like the table about user definable / overloadable operators make not really sense. Only a few languages use real operators and allow user definable new operator symbols with priority and associativity. Because of the many me too languages this information is not clearly visible. Georg Peter 07:17, 30 October 2007 (UTC)
We have a bad example; adding two dates doesn't make sense, just as adding two pointers doesn't. We should change it into adding two durations of time, or two lengths, etc. — Musiphil ( talk) 19:07, 18 March 2009 (UTC)
Adding dates or pointers makes perfect sense for some applications. My concern is more practical in nature.
I would make the changes myself if I understood operator overloading and classes, but I never needed to use them in my work. In some ways that makes me the perfect audience but I cannot figure out the examples because:
1 I never used operator overloading and the concept is alien to me, as is classes
2 the examples do not have a specification explaining in plain language exactly what they are supposed to be doing to which nor are the special data types defined
3 the examples lack line-by-line comments exactly what each line is accomplishing
4 the code is not 'self-documenting' directly from the syntax, especially in the third example which I cannot even make out what its intent is let alone what it is doing
I think we all get the idea of operator overloading being subtle and confusing due to syntax, but that is not what is making this code difficult to understand nor is it pointing out to me why I should care.
Could you please add some declaration of data type and plain language pecification/description of the intended input, operation, and output of each of the three examples? Lacking that, how about line-by-line comments and a general description of what the third cryptic example does?
Then, how about pointing out specifically what is important about the operator overloading, with respect to the second and third examples?
Specifically, I fail to see what the point is for using a 'hidden' variable in the second example. I consider it poor coding style to use global variables without a good reason and in this case it only seems to be justifying the need for a class instead of a simple overload.
What about the global variable justifies the need for a class? Is it the lack of a lhs operand for a typically binary operator? If so, can we have sample instantiation because otherwise the implication is that it uses the same instantiation as the first example? Please state it clearly because it still has me baffled, like I said I never used classes, I did not need object oriented code. I would need to understand everything about classes and operator overloading already to understand the example and in that case what is the point of the encyclopedia?
In the third example I do not even know what it is for. I see no connection between it and the prior two examples, nor is there an instantiation or declaration of data type or anything, nor do I see that it even accomplishes anything since it seems to set everything to zeros. What are its operands? It seems like a ghost that returns no output at all.
Maybe too you could mention some practical implications of the chosen syntax for the overload and alternative coding to mitigate, like what I had to be concerned with such as for example (maybe not my specific concerns for these operator overload samples but similar in character to):
1 potential surprise pointer overflows from improper boundary conditions, and how to prevent this without relying on the compiler to catch it for you, letting J-bird Hacker Jones hijack your browser with data execution and clean out your bank account
2 unexpected processor or memory or stream overhead while executing the code due to practical hardware limitations on bandwidth, flushing the cache for unnecessary jump instruction, multiplying by 2 instead of left shifting, etc.
3 automatic compiler error-checking overhead that might get wrapped around the assembly language, that either mitigates or causes such non-transparent issues, and how to avoid the need for relying on the compiler to clean up sloppy code for you
4 'if' statements instead of modulo operators makes the code longer and more confusing since no one would ever code this way unless processor bandwidth or some other practical hardware constraint demanded it. Can we have examples that make sense mathematically and functionally, so that we can concentrate on the issue of operator overloading?
C syntax is confusing enough without leaving people that should be able to read this encyclopedia entry with ease scratching our heads in puzzlement. Please? thx —Preceding unsigned comment added by 75.79.69.67 ( talk) 13:51, 21 January 2010 (UTC)
Is this really an either/or situation? Are there no programming languages which allow both overloading existing operators, and defining new ones? After all these years I finally ran into a situation where having both features might be desirable in limited cases. Since my available tools are already pretty much set in stone, this is pretty much just an academic question, but I'm still interested. — Preceding unsigned comment added by 85.156.251.154 ( talk) 21:37, 31 October 2011 (UTC)
mod 5 4
is the same as 5 `mod` 4
and 1 + 2
is the same as (+) 1 2
).
strcat (
talk)
12:05, 2 November 2011 (UTC)
The phrase "claimed to be useful" is not NPOV and uses weasel words. I will remove it. Dpsanders ( talk) 05:06, 19 August 2013 (UTC)
Is there a chance that someone can take a step further back in the discussion and try to explain this to a more novice programmer? I am one such programmer (FORTRAN off & on for many years, Pascal, BASIC) but I have no idea what the author is saying. Operator Overloading remains a mystery to me after reading the article.
Thanks for considering — Preceding unsigned comment added by Mark B 64151 ( talk • contribs) 00:17, 4 December 2014 (UTC)
This article lists Smalltalk as one of the languages that allows operator overloading, but I found a textbook on Smalltalk that seems to contradict this. Methods and operators in Smalltalk can be overridden, but I'm not sure if they can be overloaded. Jarble ( talk) 17:34, 9 July 2020 (UTC)