tracker issue : CF-3042143

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

Bug 84120:Overloading of operators and standard functions in components

| View in Tracker

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

Reporter/Name(from Bugbase): Sebastian Zartner / Sebastian Zartner (Sebastian Zartner)

Created: 09/10/2010

Components: Language

Versions: 9.0.1

Failure Type: Unspecified

Found In Build/Fixed In Build: 0000 /

Priority/Frequency: Trivial / Unknown

Locale/System: English / Platforms All

Vote Count: 0

Problem:

Overloading of operators and standard functions in components. Surely one of the features requested many times is the possibility to overload certain functions in CF as well as operators.Functions would be the constructor as well as an output function (in the example called toString()), which is called when an object is meant to be output. Operators is meaning all kinds of operator types (arithmetic, boolean, decision, string and ternary).See the steps to reproduce for some examples.
Method:

<!--- CFC ---><cfcomponent name="person">  <cfproperty name="firstName" type="string" getter="true" setter="true">  <cfproperty name="lastName" type="string" getter="true" setter="true">  <cfproperty name="gender" type="string" getter="true" setter="true">  <cfproperty name="age" type="numeric" getter="true" setter="true">  <cffunction name="init">    <cfargument name="firstName" type="string">    <cfargument name="lastName" type="string">    <cfargument name="gender" type="string">    <cfargument name="age" type="numeric>    <cfset setFirstName(ARGUMENTS.firstName)>    <cfset setLastName(ARGUMENTS.lastName)>    <cfset setGender(ARGUMENTS.gender)>    <cfset setAge(ARGUMENTS.age)>  </cffunction>  <cffunction name="+">    <cfargument name="operator1">    <cfargument name="operator2">    <cfreturn new person(lastName=operator1.lastName, age=0)>  </cffunction>  <cffunction name="toString" returntype="string">    <cfreturn "#getFirstName()# #getLastName()#">  </cffunction></cfcomponent><!--- CFM ---><cfset dad = new person("Michael", "Brown", "male", 34)><cfset mom = new person("Caroline", "Brown", "female", 30)><cfset child = dad + mom><cfset child.setFirstName("Claudia")><cfset child.setGender("female")><cfoutput>#child#</cfoutput> <!--- outputs "Claudia Brown" --->
Result:

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

Watson Bug ID:	3042143

External Customer Info:
External Company:  
External Customer Name: Sebastian Zartner
External Customer Email: 4E7365D64550DB12992015D5
External Test Config: 09/10/2010

Attachments:

Comments: