Maybe I'm doing something else wrong then.  I had a pseudo-constructor doing the 
following:

<cfset this.var1 = "some value">

but when i would do a cfdump inside various methods of the CFC, the "this" scope did 
not include "var1".  It was as if the pseudo-constructor did not execute (which may 
have been the problem, I'm still researching it).

However when I changed the code to:

<cfset variables.var1 = "some value">

...it worked fine. and all the "Variables" scoped things were accessible.  Are there 
different rules for "this" when used in the pseudo-constructor?

My apologies if this has been discussed at length before.  I wouldn't be offended if 
someone just pointed me to an archive.

Thanks,
nolan



-----Original Message-----
From: Sean A Corfield [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 11, 2004 4:23 PM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] scope reality check


On Mar 11, 2004, at 4:04 PM, Nolan Erck wrote:
> the "var" scope and the "this" scope are equal, and both mean "local 
> to the function/method".  Correct?

No. 'var' means local to the function invocation, 'this' means *PUBLIC* 
to the instance.

> is the Variables scope "private" for the entire CFC?  But not 
> accessible from the calling template?

Sort of. Strictly speaking 'variables' is "non-public" for the instance 
- it is accessible in components that extend your cfc (so it is more 
like 'protected' in Java).

Note that both 'variables' and 'this' exist for the entire lifetime of 
the CFC instance. 'var' exists only for the function invocation (and is 
created afresh for each new function invocation).

Regards,
Sean

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev'
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to