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 -------
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 http://dale.fraser.id.au -----Original Message----- On 7/28/06, > > 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 -~----------~----~----~----~------~----~------~--~--- |
- [cfaussie] Re: variables.instance Dale Fraser
- [cfaussie] Re: variables.instance Mark Mandel