Make Hashtbl.find_all tail recursive via a tail_mod_cons annotation#11354
Make Hashtbl.find_all tail recursive via a tail_mod_cons annotation#11354xavierleroy merged 4 commits intoocaml:trunkfrom
Conversation
|
Out of curiosity, did you test that it is indeed tail-recursive? (How?) |
Yes, I tested it. The following example terminates with the new code, but results in a stack overflow with the 4.14 Stdlib (tested with ocamlc and ocamlopt): |
|
On my machine, this example terminates correctly on trunk without any additional change, with both ocamlc and ocamlopt. |
Isn't that because stacks are heap-allocated on trunk, so we never get stack overflows ? |
Aren't there warnings 71 and 72 for this ? |
The warnings do not protect, for example, against a typo in the attribute name. |
|
In OCaml 5 stack limits are quite large, so it's better to explicitly set a low stack limit to run these kind of tests, e.g. |
Aha! That makes testing easier. On my machine, using trunk and setting 10000 for both the stack limit and the number of iterations in the test code, I get a a stack overflow. Using trunk with the change in Stdlib, I can keep the low stack limit and increase the number of iterations by 100x and the test runs fine. |
gasche
left a comment
There was a problem hiding this comment.
I am now convinced thanks to the testing report. Thanks!
|
@ferminr would you like to include a Changes entry for OCaml 5.1, or is it intentional not to? |
Ah, yes, I'll add an entry in Changes. What do folks normally do? Add the entry when the PR is first submitted, or wait until it's reviewed and approved? |
|
Does the approval of this PR mean we are now allowed to apply TRMC to |
|
@nojb I don't see why not, but I find it reassuring that it would be for 5.1 rather than 5.0. |
This fixes #8676, which had to wait for 5.x.