[ https://issues.apache.org/jira/browse/JEXL-369?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17532264#comment-17532264 ]
Dmitri Blinov edited comment on JEXL-369 at 5/5/22 2:15 PM: ------------------------------------------------------------ Henri, could you please provide the vision of what should be changed with introduction of let ? Are we adding nested block-scoped variables like in JS or simply {{let}} is a new \{{var}} in lexical mode ? May be this is not strictly relates to the ticket, but one of the things with lexically scoped variables that I think we should consider is grammar change to disallow single-statement variable declarations in lexical mode (as of now or with let). For example {{if (cond1) var x = 0;}} If we look at other languages, like JS or Java, this is not allowed. The statements where single-statement variable declarations should be disallowed are {{{}if/else{}}}, {{{}while{}}}, {{{}do{}}}, {{{}for{}}}. For compatibility reasons in non-lexical mode we can keep the existing grammar. If my work may be of any reference, here is what I did. FunctionStatement() is named function declaration like \{{function x() ... }} and so I also restricted it in lexical mode. {code:java} void StatementBranch() #void : {}{ LOOKAHEAD(1) Block() | LOOKAHEAD({!getFeatures().isLexical()}) GenericStatement() | Statement()} void GenericStatement() #void : {}{ <SEMICOL> | AnnotatedStatement() | LOOKAHEAD(FunctionStatementLookahead()) FunctionStatement() | LOOKAHEAD(DeclareLocalVar()) VarStatement() | LOOKAHEAD(Expression()) ExpressionStatement() ... void Statement() #void : {}{ <SEMICOL> | AnnotatedStatement() | | LOOKAHEAD(Expression()) ExpressionStatement() ...{code} was (Author: dmitri_blinov): Henri, could you please provide the vision of what should be changed with introduction of let ? Are we adding nested block-scoped variables like in JS or simply {{let}} is a new \{{var }} in lexical mode ? May be this is not strictly relates to the ticket, but one of the things with lexically scoped variables that I think we should consider is grammar change to disallow single-statement variable declarations in lexical mode (as of now or with let). For example {{if (cond1) var x = 0;}} If we look at other languages, like JS or Java, this is not allowed. The statements where single-statement variable declarations should be disallowed are {{if/else}}, {{{}while{}}}, {{{}do{}}}, {{{}for{}}}. For compatibility reasons in non-lexical mode we can keep the existing grammar. If my work may be of any reference, here is what I did. FunctionStatement() is named function declaration like {{function x() ... }} and so I also restricted it in lexical mode. {code:java} void StatementBranch() #void : {}{ LOOKAHEAD(1) Block() | LOOKAHEAD({!getFeatures().isLexical()}) GenericStatement() | Statement()} void GenericStatement() #void : {}{ <SEMICOL> | AnnotatedStatement() | LOOKAHEAD(FunctionStatementLookahead()) FunctionStatement() | LOOKAHEAD(DeclareLocalVar()) VarStatement() | LOOKAHEAD(Expression()) ExpressionStatement() ... void Statement() #void : {}{ <SEMICOL> | AnnotatedStatement() | | LOOKAHEAD(Expression()) ExpressionStatement() ...{code} > 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)