Allow recursive bindings with _#486
Closed
OlivierNicole wants to merge 3 commits intoocaml:trunkfrom
OlivierNicole:underscore-in-letrec
Closed
Allow recursive bindings with _#486OlivierNicole wants to merge 3 commits intoocaml:trunkfrom OlivierNicole:underscore-in-letrec
OlivierNicole wants to merge 3 commits intoocaml:trunkfrom
OlivierNicole:underscore-in-letrec
Conversation
| (* the GNU Lesser General Public License version 2.1, with the *) | ||
| (* special exception on linking described in the file LICENSE. *) | ||
| (* *) | ||
| (**************************************************************************) |
Member
There was a problem hiding this comment.
Please don't use headers in testsuite files. Especially headers with the wrong names...
| * effect to avoid testing evaluation order. *) | ||
| let test = | ||
| let rec _ = p "1"; p "2" | ||
| and x = p "1\n2"; 3 |
Member
There was a problem hiding this comment.
It'd be good to have the bindings used recursively in the test -- i.e. use x in the rhs of y and vice versa, and also use them both in the rhs of the _ bindings.
Member
|
Could you please add an entry to |
Contributor
Author
|
After modifying the test as you suggested, it makes my code crash because of an unknown identifier, because of the way I translated "_"-bindings into a sequence. I am working on the problem. So this PR is faulty, sorry about that. |
lukemaurer
added a commit
to lukemaurer/ocaml
that referenced
this pull request
Jul 7, 2021
This includes ocaml#485.
mshinwell
pushed a commit
to mshinwell/ocaml
that referenced
this pull request
Jul 13, 2021
The decision logic is intended to be unchanged from the ancien régime, with the exception that unrolling state is preserved between the simplification of a recursive function's body and any re-simplification that occurs due to inlining.
stedolan
pushed a commit
to stedolan/ocaml
that referenced
this pull request
May 24, 2022
EmileTrotignon
pushed a commit
to EmileTrotignon/ocaml
that referenced
this pull request
Jan 12, 2024
* add a carousel-style books component * allow books to be navigated using a keyboard
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.
Description of the problem from the Compiler hacking wiki:
Currently, you cannot use _ in recursive bindings:
This is because patterns aren't allowed there, only variables. Really _ should be considered a variable in this context.
What has been done
Just like with
letbindings,_is now allowed as a variable name inlet recbindings. As withletbindings, this construction is translated into a sequence.A test has also been added to the test suite to make sure that
_bindings work and can produce effects. Evaluation order is not tested as it may be changed by flambda.