The arguments scope is copied into the local function scope after the
cfargument tags, so all arguments are also in the local var scope.

You can see this in action with the following code:

<cffunction name="test">
        <cfargument name="testvar" type="string" default="I'm an argument"
/>

        <cfdump var="#arguments#" label="Arguments scope" />
        <cfdump var="#getPageContext().getActiveFunctionLocalScope()#
label="Function local scope" />

        <cfoutput>Initial Argument value: #arguments.testvar#<br
/></cfoutput>

        <cfset testvar = "I'm a local variable" />

        <cfoutput>
                local variable value: #testvar#<br />
                argument value: #arguments.testvar#<br />
        </cfoutput>

        <cfset arguments.testvar = "I'm a modified argument value" />

        <cfoutput>
                local variable value: #testvar#<br />
                argument value: #arguments.testvar#<br />
        </cfoutput>

        <cfdump var="#arguments#" label="Arguments scope" />
        <cfdump var="#getPageContext().getActiveFunctionLocalScope()#
label="Function local scope" />
        
</cffunction>

<cfoutput>
#test()#
</cfoutput>

Spike


--------------------------------------------
Stephen Milligan
Code poet for hire
http://www.spike.org.uk

Do you cfeclipse? http://cfeclipse.tigris.org 


 

>-----Original Message-----
>From: [EMAIL PROTECTED] 
>[mailto:[EMAIL PROTECTED] On Behalf Of 
>Barry Beattie
>Sent: Sunday, May 30, 2004 11:46 PM
>To: CFAussie Mailing List
>Subject: [cfaussie] argument scope = var scope within functions?
>
>"Cannot declare local variable tempNoteText twice"
>
>I'm not. I'm declaring an argumnent within a function and then 
>using a variable with the same name in var (local) scope. 
>
><cffunction name="splitNotes" output="No" returntype="array">
>   <cfargument name="tempNoteText" required="Yes" type="string">
>   <cfset var tempNoteText = trim(ARGUMENTS.tempNoteText)>
>
>so the local function scope includes the argument scope - it's 
>not 2 different ones. I suppose that's buried somewhere within 
>the docs for me to RTFM but I really didn't think it'd be the 
>case. I suppose it makes sence but gee
>
>...I'd *REALLY* like private variables in CFFUNCTION to be 
>*REALLY* private
>
>cheers
>barry.b
>
>
>
>---
>You are currently subscribed to cfaussie as: 
>[EMAIL PROTECTED] To unsubscribe send a blank email to 
>[EMAIL PROTECTED]
>
>MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia 
>http://www.mxdu.com/ + 24-25 February, 2004


---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia
http://www.mxdu.com/ + 24-25 February, 2004

Reply via email to