Skip to content

remove Lazy in typing/#12807

Merged
gasche merged 1 commit intoocaml:trunkfrom
gasche:no-lazy-in-typing
Dec 15, 2023
Merged

remove Lazy in typing/#12807
gasche merged 1 commit intoocaml:trunkfrom
gasche:no-lazy-in-typing

Conversation

@gasche
Copy link
Copy Markdown
Member

@gasche gasche commented Dec 5, 2023

We are trying to avoid using the 'lazy' machinery in the part of the compiler distribution that is used during bootstrap (to build ocamlc.byte). This avoids depending on the arguably complex runtime support for lazy, and it makes it easier to change this runtime support.

As discussed with @lthls yesterday, there was a use of lazy in typing/ctype.ml which does not appear to require any sharing/memoization; we replace it by unit -> 'a thunks. (I find it a bit surprising that we would use lazy when unit -> 'a suffices, so I would be reassured by a confirmation by @garrigue that the change is indeed correct.)

We are trying to avoid using the 'lazy' machinery in the part of the
compiler distribution that is used during bootstrap (to build
ocamlc.byte). This avoids depending on the arguably complex runtime
support for lazy, and it makes it easier to change this runtime
support.

There was a use of `lazy` in typing/ctype.ml which does not appear to
require any sharing/memoization; we replace it by `unit -> 'a` thunks.
@sidkshatriya
Copy link
Copy Markdown
Contributor

Might it be useful to have a CI test that grep's for lazy in the required files that are part of the compiler bootstrap ? That way anyone inadvertently adding lazy in the future will fail the test.

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Dec 5, 2023

I am not sure that the extra complexity/ceremony is worth it: we will have false alarms for people that use lazy in comments, etc., so it is likely that the check creates more work for us.

Copy link
Copy Markdown
Member

@Octachron Octachron left a comment

Choose a reason for hiding this comment

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

The delayed_copies reference is never published outside of copy_sep, and it is traversed only once before leaving the copy_sep function. That seems obviously correct to me?

@gasche
Copy link
Copy Markdown
Member Author

gasche commented Dec 15, 2023

The AppVeyor CI failed due to the usual spurious failure in memory-model/forbidden ( #12425 ). Merging.

@gasche gasche merged commit cc33887 into ocaml:trunk Dec 15, 2023
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.

3 participants