What's the actual output versus the expected output?  I'd say expected
would be this:

scopetest scope
unknown scope
parent scope
unknown scope
this scope

unscoped (your unknown scope) is shorthand for the variables scope. 
the 'this' scope is actually a subscope of 'variables', so #this.test#
is equivalent to #variables.this.test# from within the CFC.  The
'variables' scope (including the 'this' scope) is inherited by
subclasses.  Your "special" object-name scope, is nothing more than a
struct inside the 'variables' scope, exactly as you'd expect to have
happen in "normal" CFML code.  Since the 'variables' scope is private,
your new struct is also private.

cheers,
barneyb

On Thu, 6 Jan 2005 14:37:18 +1000, Taco Fleur <[EMAIL PROTECTED]> wrote:
> Following is just interesting, when I read about CFC scopes I always hear
> about the private and public scope, i.e.
> 
> this.test = public
> variables.test = private
> test = private
> 
> But it appears that the name of the object is also a (seperate) private
> scope, see following:
> 
> ****** Save as ScopeTest.cfc
> <cfcomponent extends="Parent">
> 
>      <cfscript>
>      ScopeTest.test = "Hello there! I'm in the ScopeTest Scope";
>      variables.test = "Hello there! I'm in the ScopeTest Variables";
>      //Parent.test = "Hello there! I'm in the Parent Scope";
>      test = "Hello there! I'm in the unknown Scope";
>      this.test = "Hello there! I'm in the this Scope";
>      </cfscript>
> 
>      <cffunction
>           name="test1"
>           access="public"
>           returntype="string">
> 
>           <cfreturn ScopeTest.test>
>      </cffunction>
> 
>      <cffunction
>           name="test2"
>           access="public"
>           returntype="string">
> 
>           <cfreturn variables.test>
>      </cffunction>
> 
>      <cffunction
>           name="test3"
>           access="public"
>           returntype="string">
> 
>           <cfreturn Parent.test>
>      </cffunction>
> 
>      <cffunction
>           name="test4"
>           access="public"
>           returntype="string">
> 
>           <cfreturn test>
>      </cffunction>
> 
>      <cffunction
>           name="test5"
>           access="public"
>           returntype="string">
> 
>           <cfreturn this.test>
>      </cffunction>
> 
> </cfcomponent>
> 
> ***** Save as Parent.cfc
> 
> <cfcomponent>
> 
>      <cfscript>
>      Parent.test = "Hello there! I'm in the Parent Scope1";
>      </cfscript>
> 
> </cfcomponent>
> 
> ****** Code to test
> 
> <cfscript>
> Object = createObject( "component", "ScopeTest" );
> </cfscript>
> <cfoutput>
> #Object.test1()#<br>
> #Object.test2()#<br>
> #Object.test3()#<br>
> #Object.test4()#<br>
> #Object.test5()#<br>
> </cfoutput>
> 
> Is this already documented and known, or am I off with the fairies again??
> You would think that [object name] would be the same as [this], not?
> 
> Taco Fleur

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 9 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support 
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:189476
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to