Skip to content
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

plutus-ir: allow lets to be strict or non-strict #1127

Merged
merged 3 commits into from Jun 12, 2019

Conversation

michaelpj
Copy link
Contributor

This implements a feature I discussed before on the mailing list: non-strict (possibly should be CBN) let-bindings in PIR.

This has a couple of advantages:

  • We can simplify the plutus-tx code significantly, removing some restrictions in the process.
  • We can simplify the recursion-thunking code, at the cost of being slightly less clever.
    • Previously we introduced an "adaptor" binding so that the body of the let would see a non-thunked binding. Using non-strict let-bindings means that the body will now see the thunked binding, but this doesn't matter that much in practice.

There is one con at the moment:

  • We generate the unit type and values at each use site in PIR, since we don't have definitions support there. I should fix this, but I don't know how much this will actually save.

I also fixed the value check in PIR. In particular, it thought that variables were values, which is definitely wrong. As a result we now compile a lot more cases non-strictly, in particular a lot of trivial cases on booleans. But again, I think this doesn't matter so much and it's much more correct.

We still have logic for compiling cases non-strictly in plutus-tx. I want to add case expressions to PIR to handle this, but I'll do that in a separate PR.

Copy link
Contributor

@effectfully effectfully left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

- Replace all references to `x` in `body` with `x ()`

To avoid quadratic behaviour, we do the latter substitution in one go, by collecting
all the substitutions to do as we go, and then doing them in one go at the end.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is called "simultaneous substitution", I believe.

@michaelpj michaelpj merged commit 183d156 into IntersectMBO:master Jun 12, 2019
@michaelpj michaelpj deleted the imp/let-strictenss branch June 27, 2019 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants