[ https://issues.apache.org/jira/browse/JEXL-369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17532407#comment-17532407 ]
Dmitri Blinov edited comment on JEXL-369 at 5/5/22 4:48 PM: ------------------------------------------------------------ In JS you may have a variable redeclared in nested block unlimited number of times {code:java} let x = 1 { let x = 2; { let x = 3; } // x = 2 } // x = 1 {code} In JEXL in lexical mode (like n java) it is not possible to declare a variable in nested block if it has already been defined in outer block. {code:java} var x = 1; { // error here var x = 2; }{code} To illustrate how JS variables work (redeclaration, hoisting and capturing) lets consider the dummy example {code:java} var x = 1; if (x === 1) { let x = 2; console.log(x); // expected output: 2 { // let x = 3; var ddd = function() {return x = x +1} let x = 4; } console.log(x) console.log(ddd()); } console.log(x); // expected output: 1 console.log(ddd()); {code} The output is 2, 2, 5, 1, 6 was (Author: dmitri_blinov): In JS you may have a variable redeclared in nested block unlimited number of times {code:java} let x = 1 { let x = 2; { let x = 3; } // x = 2 } // x = 1 {code} In JEXL (like n java) it is not possible to declare a variable in nested block if it has already been defined in outer block. To illustrate how JS variables work lets consider the dummy example {code:java} var x = 1; if (x === 1) { let x = 2; console.log(x); // expected output: 2 { // let x = 3; var ddd =function() {return x = x +1} let x = 4; } console.log(x) console.log(ddd()); } console.log(x); // expected output: 1 console.log(ddd()); {code} The output is 2, 2, 5, 1, 6 > Add 'let' and 'const' variable declarations > ------------------------------------------- > > Key: JEXL-369 > URL: https://issues.apache.org/jira/browse/JEXL-369 > Project: Commons JEXL > Issue Type: Improvement > Affects Versions: 3.2.1 > Reporter: Henri Biestro > Assignee: Henri Biestro > Priority: Major > Fix For: 3.3 > > > WHAT: > Add creation of lexical scope variables, modifiable with 'let', > non-modifiable through 'const'. -- This message was sent by Atlassian Jira (v8.20.7#820007)