Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up`grab` expressions #318
Conversation
bvssvni
added some commits
Jun 24, 2016
bvssvni
merged commit 69ba217
into
PistonDevelopers:master
Jun 26, 2016
bvssvni
deleted the
bvssvni:capture
branch
Jun 26, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
bvssvni commentedJun 24, 2016
•
edited
This PR adds
grabexpressions to Dyon. For design, see #316.What is a
grabexpression?A
grabexpression is a partial evaluation operator that evaluates expressions in the closure environment. This can be used to capture variables read-only.Higher order functions
The
grabexpression allows you compute with higher order functions, such as function currying, composition of traversing operators, etc.Code generation
grabexpressions can be used as form of run-time code generation:This has the following benefits:
Motivation
Before, closures in Dyon could not capture variables from their envionment. With
grabexpressions they can, and gives you more precise control over how this happens.Adds a non-state capture ability of variables in the environment of closures. It is more powerful in the way that it works as a partial evaluation operator, but less flexible than mutable captured variables.
Dyon uses current objects for mutating the environment, so there is less need for capturing mutatable variables. A non-state capture is easier to reason about, requires no lifetime, and does not add overhead when calling closures.