Skip to content
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

A command-line option to tell the compiler to behave (somehow) as a specific version #7184

Closed
vicuna opened this issue Mar 17, 2016 · 9 comments

Comments

@vicuna
Copy link

vicuna commented Mar 17, 2016

Original bug ID: 7184
Reporter: @alainfrisch
Status: acknowledged (set by @mshinwell on 2016-12-08T15:06:44Z)
Resolution: open
Priority: normal
Severity: feature
Category: misc
Monitored by: @gasche @diml @hcarty

Bug description

I suggest to introduce a command-line option to tell the compilers to emulate (to some extent) the behavior of a specific older version of OCaml. E.g. "ocamlc -as-of 4.03 ...". This could include things such as:

  • Choices for various modes (safe-string, strict-formats, strict-sequence).

  • Default warning configuration (and the meaning of "a").

  • Rejecting new linguistic features (implemented e.g. within the AST invariant checker).

There would be two goals:

  • Give a quick way to check that the code base of a specific project does not start using features from a newer version of OCaml while the project is supposed to still support older versions. This would not be a bullet-proof check, of course, just a first quick check against using e.g. "match with exception" or GADT when targeting an older version.

  • Allow distributed source packages to "immunize" themselves against changes to default mode/warning configurations in future versions of OCaml, and thus allow OCaml to change those default configuration with more freedom. E.g. one could decide to turn safe-string on by default at some point, and packages which come with an explicit "as-of" flag would not be affected.

@vicuna
Copy link
Author

vicuna commented Mar 17, 2016

Comment author: @lefessan

If we go along this path (which I have think is good), a few remarks:

  • We could try to use the same options as some other compilers. For example, "javac" has a "-source" option for that, maybe easier to understand than "-as-of"
  • I don't think we should aim at satisfying the two goals of Alain, but only the second one. Compatibility with a given version should be enforced by a style-checker, not the compiler itself. Also, the goal for me would be to specify that a package, in OPAM, at a given point, compiles with a given version, so the maintainer could use "ocamlc -source 4.04" to be sure that it will keep compiling, even if "-safe-string" is set in 4.05. Now, if, for a bug fix, I start using a feature of 4.05, I don't think it should prevent the package from compiling.

@vicuna
Copy link
Author

vicuna commented Mar 17, 2016

Comment author: @dbuenzli

I'd be rather against this kind of proposal. They make it easier to split the ecosystem into packages and people using different languages while our goal should be to try to move the whole ecosystem so that we are all experiencing the same the language. It also makes debugging issues more difficult.

Regarding rejecting linguistic features I think these kind of things are best left to a separate linter tool (which could be distributed with OCaml).

@vicuna
Copy link
Author

vicuna commented Mar 17, 2016

Comment author: @lefessan

@daniel: you could see it the other way around. Such an option will help anybody to use the library from somebody else, even if that particular library was not designed to work with the same version of the compiler. So, it will actually help people to use each other's work, by removing a barrier that is currently present (and it will make the opam-repository more stable and resilient to compiler policy changes).

@vicuna
Copy link
Author

vicuna commented Mar 17, 2016

Comment author: @dbuenzli

Well I don't see it the other way round. This introduces more build noise and complexity in the system.

@vicuna
Copy link
Author

vicuna commented Dec 8, 2016

Comment author: @mshinwell

I tend to agree with dbuenzli that this seems likely to introduce more complexity than it solves. Would anyone else like to weigh in?

@vicuna
Copy link
Author

vicuna commented Feb 27, 2017

Comment author: @damiendoligez

For alain's first goal, just use opam switch to check with the actual version.

The second goal is more interesting, but I see this feature as complex and not well-specified. Which language and compiler features would be affected exactly? What about the standard library? And can you guarantee that code compiled with different versions will interoperate?

@github-actions
Copy link

github-actions bot commented May 9, 2020

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.

@github-actions github-actions bot added the Stale label May 9, 2020
@ghost
Copy link

ghost commented May 12, 2020

We have some experience about this in Dune since this is effectively what we do. In the case of Dune, this works really well. We can effectively go through breaking changes without pain and the latest dune binary is able to understand a wide range of projects written against different versions of Dune. We also provide an automatic upgrade tool to make it easy for authors to bring their project up to the latest standards.

However, this is manageable in the case of Dune because the surface API of Dune is small and we introduced this concept early on. Retrofitting this concept into OCaml would likely be a lot more work.

@github-actions github-actions bot removed the Stale label Jun 12, 2020
@github-actions
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant