On 10/12/07, Baz <[EMAIL PROTECTED]> wrote:
> To take this a step further now, if you are mixing in a function into other
> CFCs (by reference), and that function has code to set variables.xyz=123,
> will that variable be stored in the proper CFC?

Define "proper"...

What you have to remember is that ColdFusion is a dynamic language and
variable binding (lookup) is done at run time. That means if you have
the following function:

function getVar(x) { return variables[x]; }

and you call it in a regular CFML page like this:

<cfset variables.foo = 42 />
<cfset z = getVar("foo") />

z will be 42 - getVar will look up "variables" in the calling context
(of the page).

Now if you do this:

<cfset obj = createObject("component","MyComponent").init("somedata") />
<!--- assume .init() stores in variables.data inside the component --->
<cfset obj.myFunc = getVar />
<cfset z = obj.myFunc("data") />

z will be "somedata" - getVar() will look up "variables" in the
calling context which is now the obj CFC...

> Are there any threading
> issues or potential conflicts with doing this if had, say, 100 objects all
> sharing this function by reference?

That situation already exists in CFCs: there is only one copy of each
method, no matter how many instances of a CFC you create. So, no,
there are no threading or conflict issues beyond what already exist.
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CFCDev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cfcdev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to