[RFC] .cmt support in caml-types.el#569
Conversation
As an illustration, we have one reasonnably-sized module which results in a 10Mb .annot file (2.5 Mb .cmt; 700kB .obj), and 30% of compilation time for this module is spent generating the .annot file. Moreover, this .annot file seems to blow up the regexp parser in .emacs, so it cannot even be used for type feedback. One should mention that one drawback on relying on an external tool is that emacs must be able to locate it and pick the tool from the exact same version as the compiler used to produce the .cmt file. This means that except if some other machinery is put in place (e.g. specifying the location of this tool in some special file e.g. at the project root), it won't be possible to use a single instance of emacs to edit files compiled with two different versions of OCaml. Probably not a big deal for most people. |
Or even tools/cmt2annot 😄 |
|
While I'm completely in favor of the extinction of .annot files I'm a bit surprised by this PR. Indeed your argument for having this new tool is: "yes ocp-index already exists, but it doesn't do what I want". And for having it inside the distribution you say
Regarding your first argument, I wonder why you don't instead contribute the feature you want to ocp-index? (also the link you gave us is 3 years old, so maybe the issue is fixed now?). The second argument is typical of emacs users. What about vim, sublime-text, atom, eclipse users? |
|
Hi @trefis; please note in principle I am not proposing this for inclusion in the official distribution. Rather, like I wrote above,
In fact it was suggested by @gasche in MPR#4369 to open a PR in order to discuss and gather such feedback. Regarding the issues you raise:
As far as I know there has been no progress in the last 3 years on this front.
Thanks! |
|
The fact is that caml-types.el is part of the core distribution and that many people actually use it. It relies on .annot file but we would like to discourage people from using -annot. My understanding is that the tool proposed here is a way to modernize the "official" emacs mode for ocaml. Perhaps this mode itself should be moved itself out of the main distribution and distributed as a standalone package (together with the tool proposed here), but as long as it is not the case, I wouldn't be shocked if the tool were included. |
I'm using it. I stopped generating However there's one thing that was nice with It seems to me that tools like |
|
Yes, |
|
Tuareg uses |
@alainfrisch Tuareg already tries to detect the proper environment to set up for the compilation to be in sync with |
|
@Chris00 an excellent remark; My own #463 is a step in this direction, but currently it only says "this magic number comes from an {older, more recent} OCaml version". For older versions it would be easy to keep a log of older magic numbers to predict the specific version to use. I'm not sure what to do for future versions (it's not really possible to guess which magic number future releases will have). For the specific case of |
|
2016-04-29 14:45 GMT-04:00 Nicolas Ojeda Bar notifications@github.com:
That wasn't clear to me, apologies.
:) 2016-04-29 16:08 GMT-04:00 Nicolas Ojeda Bar notifications@github.com:
It will only contain information about the prefix of the file which |
|
As far as I understand, both I don't understand the remark about keeping old |
tools/Makefile.shared
Outdated
| beforedepend:: | ||
|
|
||
| install:: | ||
| cp cmt_lookup cmt_lookup.opt $(INSTALL_BINDIR)/ |
There was a problem hiding this comment.
You should protect $(INSTALL_BINDIR)/ against spaces — the build fails on Windows because of that.
|
If we include "cmt_lookup" in the distribution, and update caml-types.el to use it, people will soon start improving it (with PR), until it becomes either Merlin or ocp-index, or they will get frustrated with a half-baked tool. This is exactly the opposite direction of what we are currently doing, i.e. moving things out of the distribution. If we add this, then we should also think about adding ocp-indent to the distribution as an improvement for caml-mode.el broken indentation support. Why not modify caml-types.el instead to check for the presence of external tools (merlin, ocp-index, cmt_lookup, etc.) and use them when they are available (and .cmt files also) ? |
|
Hi @lefessan,
So I am not sure what would be the point of interfacing these other tools with The point of this PR is to get Having said that I do agree that putting this inside the distribution goes against the direction in which things have been moving. But then the status of the Thanks! |
|
I think that we have a decision to make here: either we decide that editor support is the land of external tools and remove The main downside of the second choice is that it encourages people to pour effort into sub-par solutions instead of strengthening existing tools. For example, the work that @nojb did here could arguably have been an excellent pull-request to improve ocp-index's The main downside of the first choice is that evidently some users are content with just
I have tried the "it's the better long-term choice to discourage people to work on X" myself (#241), and I notice that it does not really work. I would personally be of the opinion of letting those who do the work decide. If @nojb took the time to develop a nice solution for Edit: maybe the proposed solution has a too-high risk of regression, is too hard to maintain, is not the right technical choice or does not actually solve the problem (because of opam switches, for example). If so, then say it! That is a different kind of objection. |
|
Le dimanche, 1 mai 2016 à 23:19, Nicolas Ojeda Bar a écrit :
I think it should be forked into its own project in the OCaml organisation. It's again a component that could benefit of not being tied to OCaml's own release cycle. Note that its installation already occurs through a separate package in OPAM. Daniel |
There is a third solution: keep the current mode as it is, use
As far as I know,
As far as I know, both tools are available under Windows. Independently of this PR, it would be interesting to know which limitations were observed under Windows (there is no issue related to Windows on ocp-index BTR)
Then, we should include either
If cmt_lookup can do it, I don't see why it can't be done in existing tools.
I don't understand your argument. You mean that, because I always use
Are you accusing me of disrespecting the work of @nojb ? So now, when somebody disagrees with merging a PR, it's a lack of respect for the work done ? Please, could we keep the debate technical ???
That's exactly what I said: if you include this tool in the distribution, it will either start growing with new features to become Merlin, and we will have to move it outside of the distribution, or it will be kept limited, and users are going to complain that it is missing all the nice features you could also do when accessing |
|
|
The "IDE mode" front has been pretty bleak in the past years, with a split between the Caml mode and Tuareg. We now have extremely efficient replacement for on-the-fly type queries and indentation with Merlin and ocp-indent. On real-sized projects, the productivity boost obtained with Merlin -- in particular with go-to-definition -- is remarkable. I quite agree with @lefessan on the fact that awakening caml-types.el from its torpor would likely only lead to a half-baked re-implementation of Merlin. @nojb, you mentioned on Mantis that Merlin has many dependencies and is hard to install on Windows. Do you have more details on which dependency is problematic? My gut feeling is that we should strive to make the installation of Merlin painless everywhere. |
|
I have the script needed to build Merlin on windows and the final binary is relocatable. Hardest part is installation of dependencies (yojson). |
|
Indeed! It is not so much that it is not possible to install |
|
@let-def if it is pure ocaml, I find |
|
Closing this, as the discussion seems to have bottomed-out. |
64235a3 flambda-backend: Change Float.nan from sNaN to qNaN (ocaml#466) 14a8e27 flambda-backend: Track GC work for all managed bigarray allocations (upstream 11022) (ocaml#569) c3cda96 flambda-backend: Add two new methods to targetint for dwarf (ocaml#560) e6f1fed flambda-backend: Handle arithmetic overflow in select_addr (ocaml#570) dab7209 flambda-backend: Add Target_system to ocaml/utils (ocaml#542) 82d5044 flambda-backend: Enhance numbers.ml with more primitive types (ocaml#544) 216be99 flambda-backend: Fix flambda_o3 and flambda_oclassic attributes (ocaml#536) 4b56e07 flambda-backend: Test naked pointer root handling (ocaml#550) 40d69ce flambda-backend: Stop local function optimisation from moving code into function bodies; opaque_identity fixes for class compilation (ocaml#537) f08ae58 flambda-backend: Implemented inlining history and use it inside inlining reports (ocaml#365) ac496bf flambda-backend: Disable the local keyword in typing (ocaml#540) 7d46712 flambda-backend: Bugfix for Typedtree generation of arrow types (ocaml#539) 61a7b47 flambda-backend: Insert missing page table check in roots_nat.c (ocaml#541) 323bd36 flambda-backend: Compiler error when -disable-all-extensions and -extension are used (ocaml#534) d8956b0 flambda-backend: Persistent environment and reproducibility (ocaml#533) 4a0c89f flambda-backend: Revert "Revert bswap PRs (480 and 482)" (ocaml#506) 7803705 flambda-backend: Cause a C warning when CAMLreturn is missing in C stubs. (ocaml#376) 6199db5 flambda-backend: Improve unboxing during cmm for Flambda (ocaml#295) 96b9e1b flambda-backend: Print diagnostics at runtime for Invalid (ocaml#530) 42ab88e flambda-backend: Disable bytecode compilers in ocamltest (ocaml#504) 58c72d5 flambda-backend: Backport ocaml#10595 from upstream/trunk (ocaml#471) 1010539 flambda-backend: Use C++ name mangling convention (ocaml#483) 81881bb flambda-backend: Local allocation test no longer relies on lifting (ocaml#525) f5c4719 flambda-backend: Fix an assertion in Closure that breaks probes (ocaml#505) c2cf2b2 flambda-backend: Add some missing command line arguments to ocamlnat (ocaml#499) git-subtree-dir: ocaml git-subtree-split: 64235a3
Co-authored-by: tmattio <tmattio@users.noreply.github.com>
(See MPR #4369 and MPR#5812 for the discussion on Mantis)
A new tool
tools/cmt_lookupis introduced to look up type and identifier information incmtfiles (since these files contain marshalled structures they cannot easily be read byemacs).caml-types.elis adapted to use this tool for theshow-type(look up a type usingC-c C-t) andshow-ident(look up scope information usingC-c C-l) functionalities.Advantages of using
.cmtfiles.annotfiles which take quite a lot of time and space to generate, specially if using many large structural types (like objects)..annotfiles. While not yet implemented in this PR, it would be easy to add features such asjump-to-definition, etc. thanks to the additional information found in the.cmtfiles.Disadvantage of the current approach (maybe)
.annotfiles can be cached on theemacsside since they are textual; by contrastcmtfiles need to be read and parsed anew each time. However this seems to work fast enough in practice, especially if using the native-code version of the tool.Other possible approaches/improvements
cmtfile inside it..annotfile directly from thecmtfile (like in thetools/read_cmttool) and read that fromemacs. This negates the advantages of usingcmtfiles in the first place (better type information, etc.)What about
ocp-index?ocp-indexuses.cmtfiles its existing code base is not geared towards lookup of information based on location, but rather towards more global features like completion (see also Show type seems very buggy OCamlPro/ocp-index#18). Moreover, I think thatcaml-types.elis the common denominator in terms of editor support and in my view there is a need for it to work with.cmtfiles.