-
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
Effective deprecation mecanism #10393
Comments
Should we use the same "min-version" to warn when the user tries to use function marked with a |
That would be great ! |
But with We need to be able to distinguish the stdlib and then we get into how we could generalize this for use by libraries and then we get into ah but the compiler still doesn't know what a library is. Let's start simple ! |
|
For the record, I like your write up on deprecation policy, that mostly matches what I had in mind as well (we discussed deprecation policies in the past but never reached a consensus). I would be in favor of starting doing this right now -- we can indeed discussion schemes to improve this. (the |
@alainfrisch I have no idea how all this is implemented and how alerts effectively work. But yes I agree we should have in mind how it could be scaled to libraries. It seems to me that the only point to address is the cli flag. That is, it should be repeatable and the syntax should be able to specify a name, ignored for now, e.g. @gasche I think the problem with my write up is that by not warning as soon as the workaround is introduced it penalises later people who have the opportunity to act now. So it's not super user friendly (and as mentioned more bureaucratic for the dev team). Also I can perfectly see (I do however think that using |
A general design could be to add some predicate to alert annotations (in addition to the existing textual payload): val foo: int -> int
[@@alert my_alert "Blablabla" (ocaml_version >= "4.08")] When referencing such a component, the alert is triggered only if the predicate holds; the predicate can refer to some variables (that can be passed on the CLI, or specified locally through attributes, in the same way we control which warnings/alerts are enabled). ocaml_version would have a default value. (We need to use a comparison which understands the syntax of versions.) The deprecation attribute Similarly, we could introduce a If a function is discovered to be buggy in a range of (old) versions, one could do something like: Anyway, my point is that if we want to keep the internal machinery of generic alerts to support version comparison for both the existing "deprecated" and a new "since" alert (which compares in the other direction), and to do that for both OCaml version but also external libraries, we should perhaps directly extend the notion of alerts with a more general predicate mechanism, even if in practice we will only use simple predicates. |
Coming back to this statement, which problem do you see with:
Having finer-grained descriptions of versions in which a component has been deprecated (resp. introduced) helps casual contributors to X quickly detect uses of components that shouldn't be used for the expected target version for the library (OCaml N), without actually switching to that version of OCaml. It's useful, but it's just some helper (the real criterion is really whether the code will still compile with OCaml version N). (That's why I don't really understand the problem of adding deprecation warning quickly enough, even without this fine-grained versioning system; but I might miss some perspective...) |
I'm not getting your last message.
Warnings as errors should be disabled for released code. Not warnings per se.
Assume a workaround is introduced but the warning is not introduced at the same time. Now suppose you only target versions which have the workaround. You may still end up using the deprecated stuff without being warned. This will entail maintenance work later when the warning is introduced. But had you been properly warned in the first place this maintenance work could have been avoided. |
Ah. It's true that I'm working under that assumption that the current state of the tooling makes non-fatal warning rather useless (they will just be lost in the log of the compilation, with no way to see them again without forcing a recompilation of everything; I think the build system should consider warnings as outputs of the compiler, properly keep track of them, and show them again on demand, for the whole code base). But anyway, and a consumer of an external library, I'm not very interested to see (non-fatal) warnings in that foreign code (when I install it through OPAM, or when building my mono-repo where I've imported that code). Warnings are for developers, and as a consumer, I really don't care about them; if I'm ready to act on the warnings, it means I put myself in the position of a contributor for the external library. In which case are you interested to see (non-fatal) warnings when compiling "foreign code" (through OPAM, or in a mono-repo)? |
No need to convince me on that part :-) I'm clearly pushing for introducing the warning as soon as possible. |
A more solid foundation would be for the compiler to consider warnings as part of its written artefacts. That idea is floating in
I'm interested in knowing about the health of my dependencies and if they may start breaking in the future. So even as a user I'm interested in seeing them.
Then I really didn't understand what you were asking for :-) |
(Optionally) emitting |
I wanted to understand why it bothers people to add deprecation warnings as soon as possible. I can see how keeping more versioning information can bring additional convenience, but I've still a hard-time understanding what problems it would create in practice to add deprecation warnings e.g. for #10392.
If you want to know if your dependencies use functions that are/will be deprecated, enable the warnings for them (as fatal or not, depending on your preference); and then I guess you want to have the information as early as possible. If you are not interested, turn the warnings off. Knowing at which version the function have been marked as deprecated is useful, I guess, if you intend to patch the library to avoid them, but don't want to force a dependency for that library on a recent version of OCaml; but then, as any contributor to that library, you should make sure to compile with the oldest version of OCaml they want to support (and otherwise their CI will complain when you submit your patch). The extra convenience brought by keeping the version information in the deprecation attribute would allow you to avoid dealing now with the function if they only been deprecated too recently for the external library (meaning you cannot use a replacement function without forcing the library to depend on a more recent version of OCaml). This is useful, but then, for a very stable library, their author will have less incentive to force a dependency on a more version of OCaml, and thus less chance to avoid the deprecation warning in the future. At some point, either they will need to bump their minimal OCaml version requirement; or you will have to accept that their library will be broken when the functions really go away. Isn't it just pushing the problem for the future? |
Because at the moment if you do so, then for the person who needs to support earlier OCaml versions you can either:
|
Ok, thanks, I think I start to get the picture. It's really an helper to library authors (who wants the support old versions of OCaml even with the latest version of their libraries), to decide when to rewrite their code base and bump their minimum OCaml version requirement. The thing is that currently, we never really remove deprecated functions, so there is an incentive for library author to keep supporting old versions and just ignore warnings (to increase the audience). And in turn, this reduces the incentive to users to upgrade to a newer version of OCaml. At the end, I've a slight feeling that a lot of energy is put into making sure the community can avoid adopting new versions of OCaml, and some of that energy might be better spent making sure adopting new versions works fine. But I'm not a very active contributor to the ecosystem, so I'll defer to your judgment. |
I've heard rumors that the dune developers intend to improve support for warnings, so perhaps they have better ideas (or just this one exactly). |
Well not only library authors, authors in general.
The problem is that this may well be out of your control. I don't think the problem of sticking to older version is the audience, it's rather the OCaml version supported by OS package managers. If you want to create applications written in OCaml that can easily be packaged by them, then you are bound by their constraints on OCaml. See comment 2 in my deprecation write up. (There are certainly other factors like the maintenance work, risk and testing needed for upgrading the compiler used by deployed application, not everyone may afford or have the resources to cope with the new release pace of OCaml) I think the scheme proposed in this issue is the one which strikes the best balance for the user experience of deprecation managers, people who want to benefit from it asap and those who can't for good reasons. |
Is that really how it works (honest question)? I would have expected that application that turns out to be implemented in OCaml would have packaging instructions that starts by installing OCaml+OPAM and the libraries (or vendor everything, including OCaml). Is it really the case that packages depend on the OCaml compiler + OCaml libraries installed by the OS? Or do they rely on the OCaml + OPAM shipped by the OS, but external OCaml libraries are installed by OPAM? (I assume that OCaml libraries packages for various OS is a small subset of the OPAM universe, but perhaps I'm wrong.) The compatibility matrix between OCaml and ecosystem libraries + the impossibility to have multiple "global" versions of OCaml in the same OS package (or that would force to have version of all OCaml libraries packaged for each version, which would be a nightmare to maintain) would seriously restrict which version of OCaml and libraries can be used by such OCaml applications to be packaged. |
The answer is "all of the above", @alainfrisch :-)
I talked about some of the challenges here for opam in an OCaml Workshop talk a few years ago. The tl;dr is that the opam-repository has solvers that can work in all of these modes now, but that all of the modes are in fact used in the wild. @dbuenzli's deprecation proposal looks very workable to me. If you need a library for OCaml version parsing in the compiler, https://github.com/ocurrent/ocaml-version/blob/master/ocaml_version.ml#L17 can be relicensed for contribution to compiler-libs. |
Suppose you implement say Firefox in OCaml (or more realistically a nice cli tool). What you describe here is the best way of never having any user :-) The key point of the comment I linked to is: "install applications when you don't care about the underlying technology". |
I was under the impression that most Python and Javascript projects were relying on pip / npm to locally install their dependencies (instead of relying on the OS), with pip / npm themselves perhaps (or not) installed by the OS. In our case, that could be OPAM (perhaps) coming with the OS, and being responsible for installing OCaml libraries, but also the OCaml compiler itself. Anyway, I was thinking about packaging applications implemented in OCaml, not compiling such applications by end-users. Thanks again @dbuenzli and @avsm for your insights on those issues. |
This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc. |
In PR #10392 @alainfrisch notes:
I don't think turning off warnings explicitly is a good strategy, it defeats the purpose of having a deprecation procedure. But then we also don't want programmers have to live with warnings that they can't act on other than by silencing them.
@xavierleroy once asked me a write up for a deprecation procedure. I never heard anything back. But the idea there was to wait for the deprecation workaround to hit debian stable before starting the effective deprecation so that people mostly don't have to live with the warning.
However that introduces quite a bit of maintenance bureaucracy (delay between introduction of the workaround and the formal deprecation) and it may feel weird to align the project on whatever debian decides for its maintenance cycles. But that assumed the current state of affairs.
This could be simplified by if we had:
@deprecated deprecated-version
, that indicates the versiondeprecated-version
in which the feature is deprecated and the workaround introduced.-min min-version
that indicates the minimal OCaml versionmin-version
with which the source we are compiling is supposed to compile (defaults to the compiler version itself).That way you only start warning when
min-version >= deprecated-version
The text was updated successfully, but these errors were encountered: