> it appears that a variable in this scope (at the
> top of a CFCOMPONENT) is set upon each invocation of a
component.
Correct.
> What use is
> it to simply overwrite the variable every time?
Restate your question in regards to a normal CFM template. I
presume it
doesn't seem strange to you that variables set on a CFM
template get
"overwritten" each time that the template is executed. Why
would you
expect differently of a CFC instance?
The problem here is your use of the word "overwritten".
Nothing gets
"overwritten" because each instance of a CFC is a separate
object. It's
not the SAME object each time. The THIS-scoped variables in
the
pseudo-constructor of a CFC get *set* each time the CFC is
instantiated.
But it's a new variable; not an overwriting of an existing
one.
> In the Components section of the developers guide there
is the implication
> that "this" variables are comparable to instance
variables in a class.
I'd like to see the page reference for that.
BTW: you don't have "instance variables of a class", you can
only have
"instance variables of an OBJECT".
> However, they are overwritten each time an instance is
invoked.
You don't invoke an *instance*. You invoke a CFC, and it
*creates* an
instance (of that CFC). Thereafter you call methods of the
instance. Or
if you set THIS-scoped variables (which is generally
considered poor
practice anyhow), access its public variables.
> The "variables" scope seem to act more like proper
instance variables, but
> they are private. So one would have to write accessors
(get/set) for each.
Yes the VARIABLES scope is like *protected* instance
variables (not
private ones: there is no "private" variables space in CF).
And
THIS-scoped variables are *public* instance variables.
> The bottom line is that "this" is not properly described
in the documentation.
Well there's this:
http://livedocs.adobe.com/coldfusion/7/htmldocs/00000912.htm
And this:
http://livedocs.adobe.com/coldfusion/7/htmldocs/00001054.htm
I'm not sure what more you'd be expecting. There's not much
to the
concept, and that pretty much covers it.
--
Adam