[
https://issues.apache.org/jira/browse/JEXL-401?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Henri Biestro resolved JEXL-401.
--------------------------------
Resolution: Fixed
Commit
[3276e2a|https://github.com/apache/commons-jexl/commit/3276e2afe7496b4217b5ad62bf60bfe901749ebf]
> Captured variables should be read-only
> --------------------------------------
>
> Key: JEXL-401
> URL: https://issues.apache.org/jira/browse/JEXL-401
> Project: Commons JEXL
> Issue Type: Improvement
> Affects Versions: 3.3
> Reporter: Henri Biestro
> Assignee: Henri Biestro
> Priority: Major
> Fix For: 3.3.1
>
>
> WHAT:
> When a lambda captures local variables, these are copied into the lambda
> frame and behave as local variables within the lambda's scope. It would be
> convenient to alter this so that captured variables could be made read-only
> and reject side-effect operators at parsing time.
> WHY:
> This is an element of surprise for users with a Java background since
> captured variables must be final. It is also surprising when users expect
> dynamic (non lexical) scoping and would expect side effects to be carried
> thru scopes.
> The examples below illustrates the 2 ways this can be surprising.
> {code}
> let x = -42;
> const f = y -> x += y; // x is implicitly declared as a copy in the lambda
> 'f' frame
> f(42);
> // x is still -42
> {code}
> HOW:
> By introducing a new feature flag aptly named 'constCapture'. This feature
> flag determines whether captured variables are const or not (default).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)