0 Replies Latest reply on Jul 6, 2008 10:30 PM by Joubert Nel

    let statement to create lexical scope

    Joubert Nel

      I am a Lisp hacker and am wondering whether ActionScript 3 does/will support LET statements to create lexical scope, as is possible with JavaScript 1.7 ( http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7#Block_scope_with_let)

      I have googled for any indication that AS 3 supports this but couldn't find an answer.

      At the end of this post is an example in Common Lisp that illustrates the benefit.

      In the example, every time you call the function DO-COUNT, it returns the incremented value for the variable COUNTER, but the variable is not accessible outside of the functions DO-COUNT and GET-CURRENT-COUNT (the 2 functions in the lexical scope of COUNTER), thus enabling safe access to state.

      Joubert Nel