In that vein, I've seen someone (I forget who, so if you are on this
list, please forgive me), do something like this:

(pseudo-code for a cfc)

function init(arg1,arg2) {

        make new instance of cfc
        ob.setArg(arg1);
        ob.setArg(arg2);
        return ob;
}

and in the caller:

<cfset foo = createObject("component","thecfc").init("your","mother")>


I believe it was Brendan O'Hara who posted that bit a while back. However, this further points out that this approach is clearly a "hack," whether it's official or not. A true implementation of a constructor would provide for a method to be named the same as the CFC and have its code executed on initialization. A cleaner implementation would allow for multiple methods with the same name as the CFC to be allowed along with different arguments in each (overriding), but that's getting a bit ahead of ourselves!! As Bill Murray eloquently put it in What About Bob?, "baby steps, baby steps."


A quick check of the LiveDocs reference for MX (non-Red Sky) for the cfcomponent tag does indeed say:

Code within the body of this tag, other than cffunction tags, is executed when the component is instantiated.

Regards,
Dave.

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


----------------------------------------------------------
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