Fair call. But CFMX *is* "compiled" to Java, so that's when it's being done in CF too - albeit via a circuitous route - surely?
No. A function in CF is actually compiled to a class in Java and the 'call' to the function is dynamically looked up and compared for type compatibility at runtime. All of CF's type checking is done at runtime, not (Java) compile time.
My only thought regarding this (and this is for the purpose of conversation, not validating my idea, or suggesting a solution), would be force casting (javacast()) where the argument sets could be interpretted ambiguously.
That would remove one of the benefits of overloading - namely that you can add more refined functions to handle existing calls without changing existing source code:
obj.func("1234");
If you had this already:
<cfmethod name="foo" output="false" returntype="boolean">
<cfargument name="bar" type="string" required="yes">
</cfmethod>
the call would work (because everything is a string in CF).
You could then add an optimized version for numeric arguments:
<cfmethod name="foo" output="false" returntype="boolean">
<cfargument name="bar" type="numeric" required="yes">
</cfmethod>
without touching the function call.
Requiring casts in the call means you might as well do something like this:
obj.func("numeric","1234");
<cffunction name="func" ..>
<cfargument name="type" type="string"..>
<cfargument name="value" type="any"..>
<cfif arguments.type is "numeric">
<cfreturn func_numeric(arguments.value) />
<cfelse>
<cfreturn func_any(arguments.value) />
<cfif>
</cffunction>(which of course you can already do today).
Sean A Corfield -- http://www.corfield.org/blog/
"If you're not annoying somebody, you're not really alive." -- Margaret Atwood
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
