-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
stdlib: add an experimental alert to the Effect and Domain modules #11526
Conversation
Thanks! I hope that either the alerts can happen by default (due to end users using Effect or Domain, not other internal uses of them), or the |
I'm not sure I understand the rationale behind having something special for OCaml 5.0. Why not have a general |
Alerts are now part of the documentation generated by both ocamldoc and odoc. Concerning the name, I hesitated with having a more generic Similarly, I am not sure if we want the alert to be enabled by default. |
In my experience this is a real issue: even with the One could think of improvements to the alert UI (eg hierarchical alert names
Disabled by default seems OK. We want people to use the new modules, but we provide a way to enforce not using them if the user wants to. |
Is that a goal ? Personally I'm fine with devising a more general mechanism that allows the eco-system to release "design probes" and let user know that they are. I don't feel
I think you are right. It boils down to this (if I understand correctly the overriding behaviour between file annotations and cli arguments1) :
Option 2. seems a better strategy since people will react to 1. by using file level overrides and then definitively prevent detection (unless there was some kind of super-overriding command line flag which is something that should maybe be considered). Footnotes
|
Oh yes ! If only we had a notion of library in the compiler :-) If you are going to introduce such a convention later maybe it would be a good idea to introduce use it now as far as this particular alert is concerned. I.e. call it |
I like the idea of an API-generic |
Suppose you introduce this generic alert and library developers start using it. Now suppose that you decide you want to use one specific library (marked with the experimental alert). That means you need to disable the alert wholesale, which is not great. The same happens with the "deprecated" alert; for example in #10737 we went with an ad-hoc alert instead of reusing the |
That's not entirely true, you can always selectively disable the warning at the file level on a section of code using that library. Of course it's rather inconvenient it the library usage is not localized – but then you can segregate its use via a module. If there's really a plan to introduce a more general scheme, I'm fine with keeping the alert of this PR for the "ocaml library" only. But I also think it's better to think about making it compatible with what could come in the future rather than this ad-hoc alert for ocaml 5 features. |
True.
I don't have any concrete suggestion for improvement at the moment, so am OK either way; I just wanted to point out that using generic alerts have a bit of a downside today, but as you point out there are also workarounds as well... |
Note that if the route "of attaching alerts to libraries" is followed in the future then introducing the generic alert seems the best course of action to me. The current inconveniences can be (admittedly a bit painfuly) worked around and if in the future alerts are implicitely attached to a notion of source (e.g. a library name or a compilation unit). Then it will just be a matter of providing cli and attribute syntax upstream to selectively enable or disable alerts from specific source. The eco-system will need no change in its use of the alert. |
I have the impression that the summary of the discussion is that we should go go for a generic |
6068545
to
e4a0a09
Compare
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.
Since the default is not enabled I didn't get why you added all the inlined alert disables.
stdlib/domain.mli
Outdated
[@@@alert unstable | ||
"The Domain module is experimental in OCaml 5.0.\ | ||
Its interface might be refined in future versions and \ | ||
break forward compatibility." |
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.
Since the alert is now unstable
(which I think is better, it seems that's what other languages use aswell). I would suggest to drop the experimental terminology. I also wouldn't mention the version number. Besides I personally always get confused about forward and backward compatibility because the point where the person speaks from and where you read from makes it a bit unclear.
I would propose one of these formulations (repeating unstable
depends a bit on how alerts render in the docs and in the warnings which I'm unclear of right now):
The [Domain] interface may change in the future.
The [Domain] interface is unstable, it may change in the future.
The [Domain] interface may change in incompatible ways in the future.
The [Domain] interface is unstable, it may change in incompatible ways in the future.
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.
It is generally useful to err on the stricter side in the compiler code base itself. For instance, we want to make it harder to introduce surreptitiously effects and effect handlers in the typechecker.
Good point on the alert message, I was blind-sided by the mechanical side of the update. The alert is currently rendered as
Alert unstable. ...
in the documentation and
Alert unstable: module Stdlib.Domain
...
in error messages.
Thus
Alert unstable. The [Domain] interface may change in incompatible ways in the future.
seems like a good option to me.
|
||
let () = ignore @@ parse_options false defaults_w | ||
let () = ignore @@ parse_options true defaults_warn_error | ||
let () = | ||
List.iter (set_alert ~error:false ~enable:false) default_disabled_alerts |
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.
I don't understand why this is being disabled by default. In practice this means this new alert is rendered useless as people who use said API will simply not enable it and everyone else would have to enable it manually which they are extremely unlikely to do.
It feels like it defeats the purpose of the feature.
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.
The alert is still documented and available for people that want to control their use of unstable features.
I think that the root question is what is the audience of the alert?
Is it beginners? Do we want to signal to them that they should not use the new features and pester them until they discover the way to silence the alert?
Or is it more advanced users? Do we want to signal to them that the feature is still really unstable and that there is a tool available to restrict the use of those features in their project if needed?
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.
I think that given the way the toolchain works at the moment having enabled it disabled by default is a better strategy, see what I wrote in this comment.
For the domain module could we also get a warning regarding #11589? It is a really tricky problem and it will bite more people as 5.0 is released. |
After more discussions, there was a consensus among the maintainers that a disabled by a default Looking back at the PR, it seems better to drop the noisy testsuite changes. |
|
I meant |
bb3f95f
to
98eb6b5
Compare
stdlib: add an unstable alert to the Effect and Domain modules (cherry picked from commit d979990)
Cherry-picked on 5.0 as dc2c2bd . |
As discussed in #11074, this PR proposes to add an
experimental
alert to theEffect
andDomain
module to make it extra-explicit that the interface of those modules might change in later versions.The alert is disabled by default.
For now, I am using
ocaml5_experimental
to emphasize the point that those modules are experimental feature in OCaml 5 and make it easier to selectively enable (or disable) this alert.