I would contend CFMX supports overloading, just in a very un-java way. Instead of defining multiple methods with different argument sets, you define a single method with optional arguments. In the case where the method does really different things with different arguments, this can be a little inelegant, but the more common case where most versions of the overloaded method just set default parameters for missing ones and then call the version with all the parameters is a lot more elegant in CF. There are a number of areas where the CF implementation is less functional than the java one, but this one is at least as functional, even though it is different.

Hal Helms wrote:

Ben,

Something has puzzled me and I wonder if you'd care to comment on it: We
know that CF is a weakly-typed language, yet CFCs allow returntypes to
be defined for methods and types to be defined for arguments. If this is
done, CF will enforce some form of runtime type-checking.


What would be the major impediment to overloaded methods then? If we can
and do have runtime type-checking, wouldn't overloaded methods be at
least possible? I suspect, though, that there's something I don't
understand that would make this impractical, but I'd love to know what
it is.

Grazi,

Hal Helms
"Java for CF Programmers" class in Las Vegas, August 18-22
www.halhelms.com


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Ben Forta
Sent: Monday, August 04, 2003 5:02 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Overloading CFCs


Sean,


No, overloading is not going to be supported in Red Sky. Truth is, the
whole concept of overloading is a tough one in ColdFusion as CF is
typeless.

Your best bet is to have a method accept any and all types, and then
check to see what the type is in the method and call other code
accordingly.

--- Ben



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of sean
Sent: Monday, August 04, 2003 4:56 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Overloading CFCs


Thanks Hal. Do you know if this was fixed in Red Sky?


BTW looking forward to your class in LV.

Sean


-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hal Helms Sent: Monday, August 04, 2003 4:54 PM To: [EMAIL PROTECTED] Subject: RE: [CFCDev] Overloading CFCs

Your terms are right, Sean, but unfortunately, CFCs don't support method
overloading.

Hal Helms
"Java for CF Programmers" class in Las Vegas, August 18-22
www.halhelms.com


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of sean
Sent: Monday, August 04, 2003 2:39 PM
To: [EMAIL PROTECTED]
Subject: [CFCDev] Overloading CFCs


Hello All,




I apologize in advance as this may be a newbie question.  I am currently
working with the Mach-ii methodology and was trying to do the following
in a CFC.  I want to narrow down the error I am getting to either a
logic issue on my hand or something in the mach-ii framework.



I am basically trying to *overload* the CFC (might be confusing my terms
here).  That is if the arguments passed to setInfo is a struct, then the
second function is called, if a simple numeric value is passed, than the
first function is executed.



<cffunction name="setInfo" access="public">

                       <cfargument name="bidAmount" type="numeric"
required="true" />



<cfset this.bidAmountD = arguments.bidAmount />

                       <cfset this.bidMaxAMount = arguments.bidAmount
/>

<cfset this.bidType = 1/>

<cfset this.bidderID = 0 />

<cfset this.targetAuctionID = 97507 />



</cffunction>



<cffunction name="setInfo" access="public">

                       <cfargument name="info" type="query"
required="true" />



                       <cfset this.bidAmountD =
arguments.info.bidAmount />

                       <cfset this.bidMaxAMount =
arguments.info.bidMaxAmount />

<cfset this.bidType = arguments.info.bidType />

                       <cfset this.bidderID = arguments.info.bidderID
/>

                       <cfset this.targetAuctionID =
arguments.info.targetAuctionID />



</cffunction>



Thanks in advance.



Sean Scott

http://www.kubeworks.com {work}

http://www.kubeworks.com/personal {play}

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).







----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).


----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).




----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev' in the message of the email.


CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

Reply via email to