Ok,

 

So just to clarify for everyone. Cause it wasn't clear to me.

 

variables IS private to a CFC, it just contains other CFC object related into. Here's a sample that will make it easy to understand.

 

Test.cfm

<cfset variables.me = "HELLO" />

 

<cfdump var="#variables#" />

<cfset Test = createObject("component", "Test").init() />

<cfdump var="#variables#" />

 

 

Test.cfc

--------

<cfcomponent>

 

      <cffunction name="init">

            <cfset variables.me = "THERE" />

            <cfdump var="#variables#" />

      </cffunction>

     

</cfcomponent>

 

Outputs

-------

struct

ME

HELLO

 

 

struct

INIT

function init

Arguments:

none

Return Type:

 

Roles:

 

Access:

public

Output:

Yes

 

ME

THERE

THIS

component dmf.Deck

INIT

function init

Arguments:

none

Return Type:

 

Roles:

 

Access:

public

Output:

Yes

 

 

 

struct

ME

HELLO

 

 

THUS: the CFC can NOT access all variables. Scope and the CFM can NOT access the CFC variables scope.

 

So the only reason to use the variables.instance would be to not have the other local references such as INIT and THIS.

 

Regards

Dale Fraser

 

http://dale.fraser.id.au

 

 

 

 

 

-----Original Message-----
From: cfaussie@googlegroups.com [mailto:cfaussie@googlegroups.com] On Behalf Of Mark Mandel
Sent: Friday, 28 July 2006 13:53 PM
To: cfaussie@googlegroups.com
Subject: [cfaussie] Re: variables.instance

 

 

On 7/28/06, Dale Fraser <[EMAIL PROTECTED]> wrote:

> 

> Mark,

> 

> But I thought that the variables scope was only accessible to the CFC that

> you're using it in. Why then would you need to worry?

 

This is true, but maybe I didn't explain myself properly.

 

If I wanted to make a copy of the values in a CFC (assuming all it has

is basic types of values in the instance struct) having the instance

struct allows me to do this:

(in cfscript'ish for ease)

 

function getMemento() : Struct

{

   return duplicate(variables.instance);

}

 

And it is very easy.

 

There is no way I could go duplicate(variables), as the variables

scope has reference to LOTS of things - including UDFS that are set to

that CFC, the 'this' scope, and various other pieces.

 

It's more of a personal preference thing.  I like it because it keeps

things separate, and I don't have to worry about overlap.

 

> 

> Can the CFC access all variables. Scope, ie ones from other pages / cfc's?

 

It can access shared scopes (application, session etc), although

getting to those from a CFC is another design discussion.

 

That make a bit more sense?

 

--

E: [EMAIL PROTECTED]

W: www.compoundtheory.com

ICQ: 3094740

 

 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "cfaussie" group.
To post to this group, send email to cfaussie@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cfaussie
-~----------~----~----~----~------~----~------~--~---

Reply via email to