On Friday, August 2, 2002, at 05:35 , Jon Hall wrote:
> On my second day of using cfc's I've come to a point where I
> really want to overload a particular method.
> Is there even a way to do overloading?

No, CFMX does not support overloading - you cannot define two functions 
with the same name (which is required for overloading).

> The docs for cfargument say that if the type parameter is not one of
> the predefined types, CF will process it as a component. Unfortunately
> the docs don't elaborate (Where are the MX books?). If I use a cfc as
> the type parameter, what happens? I'm thinking CF will instantiate the
> cfc, run the constructor code, so there may be a way to determine the
> datatype of the argument passed.

No, CFMX will require that you pass (a reference to) an object of the 
correct component type. It will not instantiate the CFC because it uses 
reference semantics.

> <cfset rs = insertEmail(emailAddressString)>
> or
> <cfset rs = insertEmail(emailAddressArray)>

The only way to do this is specify 'type="any"' on your argument and have 
the function test the argument type to determine what to do with it:

        <cfif isArray(emailAddress)>
                <!--- it's an array, loop through it --->
        <cfelse>
                <!--- it's probably a string --->
        </cfif>

Note the 'probably' - "any" does no validation so you could pass a struct,
  a number... anything.

>   Can someone elaborate on exactly what happens when we use a
>   component as the datatype?

All that happens is CFMX will check the *type* of your argument, i.e., it 
must be a component instance of the same type that the cfargument tag 
specifies (or a derived component type I think... I don't have time to 
check that right now).

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to