Related, but not directly, is the weirdness with arguments vs. local
variables.  Specifically, arguments are copied to the local variables
"scope" when the method starts, so there is actually TWO copies of every
argument floating around, both of which can be changed and dereferenced
independantly.  Here's an example:

<cffunction name="test">
  <cfargument name="arg" />
  <cfset var local = structNew() />
  <cfset local.arg = "'local' scope" />
  <cfset arguments.arg = "arguments scope" />
  
  <cfoutput>
  arg = #arg#<br />
  arguments.arg = #arguments.arg#<br />
  local.arg = #local.arg#<br />
  </cfoutput>
</cffunction>

Call that function with "hello" as the argument, and you'll get this:

  arg = hello
  arguments.arg = arguments scope
  local.arg = 'local' scope

Using a psuedo-scope means you always have to dereference arguments using
the scope qualifier.  Not using it means you can ignore the arguments scope
(except for structKeyExists), not scope any local variables, and never have
to worry about using the right scope anywhere.

Cheers,
barneyb

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Jim Davis
> Sent: Tuesday, July 20, 2004 4:40 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [CFCDev] Making Persistant CFCs thread safe
> 
> My personal habit is to create a local struct as the first line of any
> method (as in <cfset var local = structnew() />
> 
> You can then just create all your variables as keys in that 
> "local scope"
> and be blissfully thread-safe.
> 
> Also remember to either var (or use the local struct) for 
> loop counters as
> well... that one will really bite you in the but.  ;^)
> 
> Jim Davis
> 
> 
> 
> 
> ----------------------------------------------------------
> 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