-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Pushing down" let bindings #44
Comments
Doing this for |
Note that we should revisit #734 once we investigate doing this pushing down. |
Will be closed by #736. |
Closed by #736 |
Our evaluator should not eliminate
let
s until they're "pushed down" to their use sites. This would permit more flexible interactive evaluation strategies in eval mode (see discussion in https://github.com/hackworthltd/vonnegut/discussions/638). It might also potentially simplify the most complicated bit of the current evaluator — see https://github.com/hackworthltd/vonnegut/pull/768#discussion_r678488543.In order to preserve the "small local changes" spirit of our reduction rules in the current eval mode, we should probably implement this as @brprice suggested (and I documented in https://github.com/hackworthltd/vonnegut/discussions/638), such that
let
s float down towards their occurrences. @georgefst also suggested that we could add an affordance to allow students to click-drag alet
to each of its use sites before eliminating it, which seems like a good idea, though it should probably be part of a suite of similar interactions, rather than just a special case interaction for eliminatinglet
s.But let's start simple. I propose that we change the current
let
elimination rule so that alet
can only be eliminated once it's adjacent to the use of the bound variable, and that we add a "push down" rule that moves alet
one step closer to its use(s), splitting thelet
into multiple equivalentlet
s when more than one child contains a use . If the latter is too annoying in practice, we can try some alternate approaches, such as @georgefst's suggestion, or just a macro step that pushes alet
all the way down to all of its bound variable's occurrences in one go.(One special case that occurs to me as I write this: Imagine we have
const x y = x
and we evaluateconst 3 2
givinglet x = 3, y = 2 in x
— we need to be able recognize and step-eliminate thelet y = 2
in this case.)See #28 for an example of why this feature would be useful.
The text was updated successfully, but these errors were encountered: