-
Notifications
You must be signed in to change notification settings - Fork 464
Remove lazy keyword #6342
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
Remove lazy keyword #6342
Conversation
@namenu Thank you for your contribution! 👍 There is still an error when running the tests though - can you have a look at that? Also note that there is more stuff that can be removed from the compiler later (handling of Pexp_lazy/Texp_lazy/Blk_lazy_general). I actually started doing this some time ago, but never finished it. 🙂 I think this can wait until v12 though as for now it is still possible to produce Pexp_lazy using .ml syntax. @cristianoc Do we want to include this PR in v11? The advantage would be that we can then have |
I would keep it for v12, and only consider non-breaking bug fixes for v11. |
@namenu Now that v11 is released and master is for v12 development - would you rebase this on the current master? |
@cknitt PR is ready, but somehow CI is not running. |
@namenu Thanks a lot! I had to approve CI for it to run. It has some errors, could you have a look at those? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks again!
@cristianoc @zth Merge?
Ah, wait - @namenu could you update the changelog, too? |
Done! |
Good to go from my end. @cknitt if you've looked through it and think it's fine then I'm fine with it for sure 👍 |
* remove lazy keyword * fix contributing doc stating old ocaml ver * sync test output * change CHANGELOG
Resolves #6241
This PR removes
lazy
keyword and modifies itself to useLazy.from_fun
andLazy.from_val
instead.limitations
The semantics were not fully compatible.
1. let rec syntax
In let rec, lazy is a specially treated grammar. 1
The following syntax could not be converted to
Lazy.from_fun
.Compiler complains with this error:
Error: This kind of expression is not allowed as right-hand side of `let rec’
2. Pattern matching with short-circuit eval
Consider following example.
Generated code prints 2 only when failed to match first case.
This imperative style isn't possible anymore. (and usually better)
Implementing
Lazy
moduleThe existing implementation was also using the
lazy
syntax directly.This was simulated with deferred function calls. (for more details, see
camlinternalLazy.res
)Footnotes
https://v2.ocaml.org/releases/4.14/htmlman/letrecvalues.html ↩