Skip to content

Add lambda captures#18954

Merged
rmuir merged 7 commits intoelastic:masterfrom
rmuir:lambda_captures
Jun 20, 2016
Merged

Add lambda captures#18954
rmuir merged 7 commits intoelastic:masterfrom
rmuir:lambda_captures

Conversation

@rmuir
Copy link
Copy Markdown
Contributor

@rmuir rmuir commented Jun 18, 2016

Painless has working lambdas now but they are incomplete, can't capture any variables from the current scope.

This adds capture support. To keep it simple nodes get a new extractVariables(Set<String>) to push their variable names. We call this on the lambda body before analysis to give us the capture info we need.

Captures work slightly differently than in java. In java they must be effectively final variables. Instead in painless they are marked read-only inside the lambda body (so you cannot assign them to a different value inside the lambda, as that would not do anything).

@uschindler
Copy link
Copy Markdown
Contributor

LGTM

@jdconrad
Copy link
Copy Markdown
Contributor

@rmuir LGTM too. Thanks for getting lambdas working!

@jdconrad jdconrad mentioned this pull request Jun 20, 2016
18 tasks
@rmuir rmuir merged commit 09305a0 into elastic:master Jun 20, 2016
@clintongormley clintongormley changed the title Painless: add lambda captures Add lambda captures Jun 26, 2016
@clintongormley clintongormley added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache and removed :Plugin Lang Painless labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement v5.0.0-alpha4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants