I agree this seems a little odd. I think I can understand why it happens the way it does but I've emailed one of the CF team to confirm my understanding and/or explain the behavior. I'll post whenever he gets back to me...

On Tuesday, Sep 9, 2003, at 13:39 US/Pacific, Brad Howerter wrote:

That's not germane because the problem occurs even if there are no variables
in the variables scope of the same name. The original example doesn't touch
the variables scope at all and there is still a problem. You could work
around it by always fully specifying ARGUMENT variable names (or, by never
specifying the argument scope).



<cffunction name="test">
<cfargument name="abc" type="string" default="foo">
<cfoutput>abc = #abc#, arguments.abc =
#arguments.abc#<br></cfoutput> <!--- this displays abc = foo, arguments.abc
= foo --->
<cfset arguments.abc = '123'> <!--- this sets arguments.abc,
but not abc in the unnamed scope --->
<cfoutput>abc = #abc#, arguments.abc =
#arguments.abc#</cfoutput> <!--- this displays abc = foo, arguments.abc =
123 --->
</cffunction>


<cffunction name="test2">
<cfargument name="abc" type="string" default="foo">
<cfoutput>abc = #abc#, arguments.abc =
#arguments.abc#<br></cfoutput> <!--- this displays abc = foo, arguments.abc
= foo --->
<cfset abc = '123'> <!--- this sets abc in the unnamed scope
--->
<cfoutput>abc = #abc#, arguments.abc =
#arguments.abc#</cfoutput> <!--- this displays abc = 123, arguments.abc =
foo --->
</cffunction>


-----Original Message-----
From: Barney Boisvert [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 09, 2003 2:25 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Unexpected CFC behaviour, please explain!


Or just make sure you always fully specify variable names, which is a good
thing to do anyway, especially in CFCs, where the unnamed scope is still
lingering and has weird behaviour compared to in 'normal' templates.


barneyb

---
Barney Boisvert, Senior Development Engineer
AudienceCentral
[EMAIL PROTECTED]
voice : 360.756.8080 x12
fax   : 360.647.5351

www.audiencecentral.com


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Behalf Of Tyler Silcox
Sent: Tuesday, September 09, 2003 1:09 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Unexpected CFC behaviour, please explain!


Yep, so I guess this is one more reason not to name "arguments." and "variables." variables the same thing...but still wack.

Tyler

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Brad Howerter
Sent: Tuesday, September 09, 2003 3:46 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [CFCDev] Unexpected CFC behaviour, please explain!


It looks like what you originally wrote is correct so long as there is no
cfargument by that name. But if there is a cfargument by that name, it is
copied into the unnamed scope and if you set it there it doesn't
get copied
back to the argument scope and if you set it in the argument
scope it isn't
recopied to the unnamed scope. Not a problem, I guess, so long as you
access the variable you've set and not the other one.


-----Original Message-----
From: Tyler Silcox [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 09, 2003 1:33 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Unexpected CFC behaviour, please explain!


That is messed up. The first example looks like arguments is just before
local variables in the order of evaluation, but the second is just wack.
There's got to be something going on here...


Tyler

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf
Of Brad Howerter
Sent: Tuesday, September 09, 2003 2:52 PM
To: '[EMAIL PROTECTED]'
Subject: RE: [CFCDev] Unexpected CFC behaviour, please explain!


That seems reasonable, but it isn't correct, as this method demonstrates:

        <cffunction name="test3">
                <cfargument name="def" type="string" default="foo">
                <cfset variables.def = 'noway'>
                <cfoutput>def = #def#, arguments.def = #arguments.def#,
variables.def = #variables.def#<br></cfoutput>
                <cfset def = '123'>
                <cfoutput>def = #def#, arguments.def = #arguments.def#,
variables.def = #variables.def#<br></cfoutput>
        </cffunction>

This prints
def = foo, arguments.def = foo, variables.def = noway def = 123,
arguments.def = foo, variables.def = noway

Apparently the unnamed scope is still with us (at least in some manner) in
6.1.


-----Original Message-----
From: Tyler Silcox [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 09, 2003 12:41 PM
To: [EMAIL PROTECTED]
Subject: RE: [CFCDev] Unexpected CFC behaviour, please explain!


When you call an un-scoped "abc", CF is going to check the local "variables" scope first, then run down the rest of the scopes until it finds a variable named "abc", which in the function test, happens to be an "arguments" variable.

Same thing goes for you when you set "abc" without a scope, it is going to
automatically set the value into the "variables" scope, which is
definitely
different from the arguments scope...(that is, unless I'm reading all of
this wrong)


So "abc" and "arguments.abc" are not the same thing. When you
call "abc" by
itself, you are really calling "variables.abc", then if it doesn't exists,
it will check for "url.abc", "form.abc", "arguments.abc", etc (not
necessarily in that order-I do not know where arguments fits in
the order of
evaluation)->


Tyler

----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word '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