ocaml-flambda / flambda-backend

The Flambda backend project for OCaml
93 stars 67 forks source link

Add `val_modalities` #2685

Closed riaqn closed 1 week ago

riaqn commented 3 weeks ago

This PR allows values in structures to have modalities.

riaqn commented 2 weeks ago

I did most of the suggestions by @lpw25 except the following:

riaqn commented 2 weeks ago

This is now ready for review. Please review the whole PR in one go - the commits are for my own tracking.

riaqn commented 1 week ago

The feature needs to be enabled by -extension mode_alpha. When it's disabled:

The above decision is driven by the example:

module M = struct let f x = x end
module M' = struct let (f @ nonportable) x = x end

For early adopters, the printed module types should be different; And that means the first should read sig val f : 'a -> 'a @@ portable while the second doesn't. However, for a normal user, finding val_modalities popping out from nowhere will be confusing. So we will use -extension mode_alpha to switch the behaviour.