Lambda and Variable Expressions and BoundExpressions - #9257
Draft
mhk197 wants to merge 4 commits into
Draft
Conversation
Merging this PR will regress 1 benchmark
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
mhk197
force-pushed
the
mk/lambda-variables
branch
from
August 7, 2026 03:06
e41b484 to
c077107
Compare
Lambda and Variable Expressions and BoundExpressions
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
…ialization docs Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Variable and Lambda get reserved expression ids alongside Root, so the unbound tree stays fully serializable. Variable carries its name in VariableOpts; Lambda carries its params in LambdaOpts and its body as its single proto child. All three reserved ids resolve before the registry lookup. Signed-off-by: Matt Katz <mhkatz97@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds lambdas and variables as
ExpressionVariants and implements the scope machinery to bind them.Binding:
Design notes
A lambda is bound by whoever knows its parameter types. They come from whatever applies it, so
Lambda::bindtakes them. That is the entry point a higher-order function will call with typesderived from its own arguments; here, tests call it directly.
Scopecarries frames, not a flat map. A flatname -> dtypemap cannot distinguish "thisbinder's own parameter" from "a name from an enclosing binder", which is what a capture check needs.
resolvereturns the dtype and the frame depth so that check is later a comparison rather than are-derivation.