Tim
02/13/2023, 9:46 PMbdw429s
02/13/2023, 10:43 PMbdw429s
02/13/2023, 10:43 PMbdw429s
02/13/2023, 10:43 PMzackster
02/13/2023, 10:58 PMbdw429s
02/13/2023, 11:00 PMbdw429s
02/13/2023, 11:00 PMzackster
02/13/2023, 11:01 PMbdw429s
02/13/2023, 11:01 PMbdw429s
02/13/2023, 11:02 PMbdw429s
02/13/2023, 11:03 PMwebsolete
02/13/2023, 11:13 PMwebsolete
02/13/2023, 11:14 PMbdw429s
02/13/2023, 11:20 PMarguments are basically namespaced inside the local struct anyway) I always just assumed they were trying to "save us from ourselves" so we wouldn't write bad code.bdw429s
02/13/2023, 11:21 PMlocal.var1 = "three";bdw429s
02/13/2023, 11:21 PMvar keyword that it complains!websolete
02/13/2023, 11:21 PMbdw429s
02/13/2023, 11:22 PMwebsolete
02/13/2023, 11:23 PMbdw429s
02/13/2023, 11:23 PMbdw429s
02/13/2023, 11:23 PMwebsolete
02/13/2023, 11:23 PMbdw429s
02/13/2023, 11:23 PMwebsolete
02/13/2023, 11:24 PMwebsolete
02/13/2023, 11:24 PMwebsolete
02/13/2023, 11:29 PM<cfset var local = structnew()> to be able to local.somevar a variable. if you didn't var local, then you ended up actually creating a variables.local struct. it was corrected/finetuned in cf9websolete
02/13/2023, 11:30 PMAdam Cameron
var a variable of the same name as a declared parameter predates the arguments and local scopes even existing. In CF5 one gets this error:
Local variable names cannot be declared more than once, nor can they conflict with parameter names.
Code:
function f(x) {
var x = 1;
return x;
}
Reason being: there were no explicit local and arguments scopes in those days, so no way to distinguish between the parameter value and the local value, so CFML disallowed it. This makes sense.
There's insufficient visibility in CF5 to check how each data structure is implemented, and the contents thereof; so dunno whether there's a reference to the arguments data structure in the local-variables data structure or not. Well: if there's a way of looking I dunno what it is. Certainly the scopes didn't exist in CF5. However this is a different thing to the rule that a function can't have a local variable with the same name as a named parameter.