tracker issue : CF-4013841

select a category, or use search below
(searches all categories and all time range)
Title:

Operator overloading

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/

Reporter/Name(from Bugbase): Adam Cameron / Adam Cameron (Adam Cameron)

Created: 06/29/2015

Components: Language

Versions: 11.0

Failure Type: Enhancement Request

Found In Build/Fixed In Build: CF11_Final /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Platforms All

Vote Count: 1

It'd be handy to be able to define what happens when objects are compared, or an element is added to a collection, and that sort of thing:

// eg 1: compareTo() method
if (obj1 > obj2) /

// eg 2: compareTo() method
function comparator(e1, e2){
    return e1 <=> e2;
}

// eg 3: add() method
myCollection + newElement; // calls add(), which might internally append the newElement to the collection

// eg 4: toString() method
writeOutput(myObject)

I don't think it would need to be a complete implementation to start with, but it's something to think about.

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	4013841

External Customer Info:
External Company:  
External Customer Name: Adam
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

It's too easy to do this yourself, and then we would get into that confusion that other languages have, does isEqual() compare object types, clean data, dirty data, heap instances, or something else? Seems to me like this needs to be on an application-by-application level, not baked into the language.
Comment by External U.
6874 | June 29, 2015 08:16:43 AM GMT
I don't think you quite get how operator overloading works, based on your comment.
Comment by External U.
6875 | June 29, 2015 08:18:05 AM GMT
................................................................
Vote by External U.
6878 | July 01, 2015 02:50:15 AM GMT
Operatore overloading is known to have its own issues because of which it is not supported in many languages.
Comment by Vamseekrishna N.
6876 | October 14, 2015 12:02:59 AM GMT
Well: out of the top ten programming languages (http://spectrum.ieee.org/) Java - no C - no C++ - yes Python - yes C# - yes R - could not determine PHP - limited JavaScript - very limited Ruby - yes Matlab - yes So more than 50% offer at least some operator overloading. Another situation relevant language that supports this is Groovy (which is like what CFML could have become had it been stewarded properly). Rust does; Go doesn't. Swift does. Scala does. Erlang doesn't seem to (but could not find a definitive source), F# does. Clojure seems to allow it. Haskell seems to. Even blimin' Perl does! I think your observation is based on the position that Java took when it decided not to do operator overloading, which is rather out of date now. Things have moved on. There are caveats to be considered when providing for operator overloading, but I don't think you are correct in writing them off as "known issues", and I think the knowledge you are basing this on is perhaps out of date, or just mired in "how Java decided to do things". CFML is a more dynamic and forward-thinking language than Java, so you should not let your Java background hold us back.
Comment by External U.
6877 | October 14, 2015 02:56:28 AM GMT