3 Replies Latest reply on Oct 18, 2013 6:57 AM by Aegis Kleais

    Feature for CF11, global LOCAL var scoping

    Aegis Kleais Level 3

      I've loved setting scopes in the following manner:


      <cfset structAppend( VARIABLES, {

           'variableName'         = 'value',

           'variableName2'       = 'anotherValue',

           'variable'                  = 'yetAnotherValue'

      }, true ) />


      It allows me to set variables in 1 command using structure notation, and keeping the command in an easy to digest look.  But a problem I've run into is that I cannot do this with the LOCAL scope and also maintain the best practice of using the 'var' keyword to ensure the variables exist only for the duration of the function call.  For example, this currently fails:


      <cfset structAppend( var LOCAL, {

           'variable1'     = 'value1',

           'variable2'     = 'value2'

      }, true ) />


      I was hoping the above would equate to the same thing as doing:


      <cfset var LOCAL.variable1 = 'value1' />

      <cfset var LOCAL.variable2 = 'value2' />


      So I'd love to see CF11 support this.  I know it's menial, but I like using structAppend because it does not remove values that already exist in the scope, but if ones that already exist are provided as well, they are tastefull overwritten.