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
Factorise bytecode and native toplevels #10124
Conversation
In principle, I'm strongly in favor, the toplevel code in general is in dire need of improvements. I can review it. Since the diffs are going to be extremely hard to read, I encourage you to add/keep/merge the interfaces everywhere, to make the refactoring as "obviously correct" as much as possible. |
@Drup thanks; this is why I try for now to do a pure reorganisation, without improvements (at least for the bytecode toplevel). Reproducing the current |
since the content didn't really match the name anymore; we need the name `Toploop` to provide a backwards-compatible interface anyway.
Update: the module names now make more sense, and the |
(except for the deprecated `directive_table`, which should be referred to through accessors)
it's used by topfind
Always forget to re-run `make alldepend` and not just `make depend` :/
Looking at |
Another thought: I'm assuming that |
Yes, there is still room for factorisation in that part (I'm assuming you mean Some functions like
Indeed! I'll add such disclaimers. |
@Drup I'm also looking at this issue as we have been working on this with @AltGr, but your review is definitely welcome. In case that's helpful, I'm using manual |
That seems reasonable.
Not excited about splitting the module, it's likely to make the logic more difficult to follow. The functor approach looks more promising to me. |
Addressed the two comments above.
|
One side effect of this PR: we are now reserving two more global names: Looks all good to me otherwise, marking it approved. @Drup do you want to review this PR before I merge it? |
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.
LGTM
The parts your mentionned were indeed straightforward to split, I had overlooked them; |
I do, give me the end of the week. |
There are a few fixes needed in the Makefile, to properly install the artifacts for The META files bundled with findlib also need an update: see ocaml/ocamlfind#10 With these precautions, I managed to compile and run topfind and utop, load libraries etc. |
The question how whether the native compiler is compiled/installed by default is a maintenance question rather than a purely technical question. I think it should be discussed in a separate issue or on caml-devel (it has been in the past), and it is best to keep it separate from the current PR. (The two questions are related, as in: if the factorization work goes well, it makes the native toplevel much easier to maintain, and the argument against not-enabling it weaker. But still I think we want to proceed in two distinct steps here.) |
@gasche that makes perfect sense, I'll amend this PR with a fix for installation that keeps it optional. |
So with these latest changes and the patch to OCamlfind, |
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.
So, it was the end of this week in the end ... :)
I just looked at the code, I think it's a great start. As @AltGr said, this is "just" a code reorganization (moving functions around, without modifying them), to lay the groundwork for more changes. I think it's pretty safe and we can merge it directly, there should be no changes in behaviour whatsoever.
The next thing to factorize is definitely the collection of eval
functions ...
module MakePrinter | ||
(O: Genprintval.OBJ) | ||
(Printer: Genprintval.S with type t = O.t) | ||
: PRINTER with type Printer.t = O.t |
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.
why the O
parameter here ? It's filled by the Obj
module in both cases ...
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.
Indeed, I just forwarded the argument to Genprintval.Make
, but that could be simplified here.
Ah one thing I just noticed is that the native toplevel used to advertise that it was native in the welcome text, which is no longer the case. That would be trivial to add back if needed ? |
I think that would be nice, it's useful to be sure that we are in the expected environment. (For example I rely regularly on the fact that it shows the OCaml version string.) |
It was dropped in ocaml#10124. It seemed cleaner and safer to add the string to the specific module used rather than trivially rely on `Sys.backend_type`. The string is left empty for the bytecode toplevel, to avoid a visible change from the current version.
- Toplevel factorisation: simplify MakePrinter functor - Re-add a discrimination string to the native toplevel header It seemed cleaner and safer to add the string to the specific module used rather than trivially rely on `Sys.backend_type`. The string is left empty for the bytecode toplevel, to avoid a visible change from the current version.
- Toplevel factorisation: simplify MakePrinter functor - Re-add a discrimination string to the native toplevel header It seemed cleaner and safer to add the string to the specific module used rather than trivially rely on `Sys.backend_type`. The string is left empty for the bytecode toplevel, to avoid a visible change from the current version.
The native toplevel has evolved from an old fork of the bytecode one, and there remains a lot of duplicated code, often with fixes only on one side.
This is an attempt at resolving this by unifying the parts that can as much as possible. It follows from #10061 and #10078.
This works but is still in a pretty rough state (needs rebasing, the
Toploop
API is broken and needs to be restored, module names need to be adjusted to match their contents, some more cleanup needed...)