commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Biestro (Jira)" <>
Subject [jira] [Commented] (JEXL-307) Variable redeclaration option
Date Wed, 02 Oct 2019 10:04:00 GMT


Henri Biestro commented on JEXL-307:

1 - Not sure I fully grasped your view on globals. Your example about variable loop visibility
does have an effect; the 'i' variable outside the loop _could_ be considered as a global.
The current stance - shared with consultants dealing with huge scripts - is that a variable
symbol should be either local or global but should *not* be allowed to be both. In essence,
if a symbol is used as a parameter or local variable in a script, it can no longer be considered
a global. 
2 - Hoisted variables handling as you describe seems sound.
3 - Pragmas are out-of-flow and should be considered as script meta-data. Some users prefer
having them declared at end of script, some at start, some at point of impact... Better doc
would help probably.

> Variable redeclaration option
> -----------------------------
>                 Key: JEXL-307
>                 URL:
>             Project: Commons JEXL
>          Issue Type: New Feature
>    Affects Versions: 3.1
>            Reporter: Dmitri Blinov
>            Assignee: Henri Biestro
>            Priority: Minor
>             Fix For: 3.2
> As of now, JEXL allows a script writer to redeclare a local variable during script evaluation.
> {code:java}
> var a = 1; var a = 2;{code}
> This may lead to potential errors with misspelled names and clashed variables. Checking
for already defined variable is a common feature of many languages. This feature can be implemented
in JEXL as an additional option of JexlFeatures class, enabled by default, thus allowing compatibility
with existing code.

This message was sent by Atlassian Jira

View raw message