You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following up on #212, the next step is copy and constant propagation, which stumped me
Generally, I would want to rewrite something like:
(let [x 1 y 2] (+ x y)
(+12)
In a generic manner with a top down strategy.
Writing a pattern which matches the biding was not difficult, and I managed to capture the bound name and the initial value
The problem is writing something which would generically walk over the body, then substitute AST nodes which reference a scoped variable with the constant nodes. I'm guessing I need something like cata, but even then, I'd have to specify all possible "shapes" the data could take in order to walk it. While the AST spec is rather small, writing out all the possible productions is verbose and slightly tedious.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Following up on #212, the next step is copy and constant propagation, which stumped me
Generally, I would want to rewrite something like:
In a generic manner with a top down strategy.
Writing a pattern which matches the biding was not difficult, and I managed to capture the bound name and the initial value
The problem is writing something which would generically walk over the body, then substitute AST nodes which reference a scoped variable with the constant nodes. I'm guessing I need something like
cata
, but even then, I'd have to specify all possible "shapes" the data could take in order to walk it. While the AST spec is rather small, writing out all the possible productions is verbose and slightly tedious.Any ideas how this could be simplified?
Beta Was this translation helpful? Give feedback.
All reactions