Open dbuenzli opened 9 years ago
You don't suggest always having those names in the environment, only when completing a top-lvel pattern / declaration ?
Sorry, didn't understand your comment.
@def-lkb wonders whether you would like the names declared in the .mli
to be available for completion everywhere in the .ml
file, or only when declaring toplevel names (let here ... = ..;;
).
Ah heu, oh I don't know, I just want to complete when it's time to complete, so I guess everywhere; but once you defined the toplevel declaration it should be available no ?
When completing in a .mli
it makes sense to have access to all names from the .ml
at all times. When completing from a .ml
, there is a difference. As you note, once a definition is done in the .ml
, it is avaiable to all successive phrases -- but right now it is not available "before" in the buffer and that is probably the right behavior, at least I personally would find it a bit surprising. Completing with the .mli
names at the place of a new declaration makes sense (especially at the toplevel), that is in a pattern, but in expressions it seems strange to suggest a completion that doesn't type-check because the name is not yet in the current environment.
Completing with the .mli names at the place of a new declaration makes sense (especially at the toplevel), that is in a pattern, but in expressions it seems strange to suggest a completion that doesn't type-check because the name is not yet in the current environment.
Agreed.
I don't think you should follow the idea that you complete only sound things. The way we (or at least I) program is not by constantly having a type-checkable source (see e.g. #273). Before @def-lkb made me switch to company-mode I have been using auto-complete mode for a long time and it had heuristics on how to find identifiers in my open buffers without knowing anything about language. There would occasionnally be noise or bogus suggestions, but there was always the right identifier in the mix and this was already a huge productivity improvement. Just let me complete that unsound thing, the next save will tell me I have to actually declare that identifier somewhere.
I.e. the tool should help me to write code, not interfere with my thinking/problem solving by mandating that I declare the identifier formally before being able to complete it.
If the change is made to show everything when performing a completion please make it optional. Most editors' built-in completion can handle context-free word completion well enough. merlin adds typing and other niceties, but those become less useful if they aren't "true" in the completion's context.
Le lundi, 27 octobre 2014 à 04:26, Hezekiah M. Carty a écrit :
If the change is made to show everything when performing a completion please make it optional.
I'm not asking for everything, I'm asking for what's in the mli.
Most editors' built-in completion can handle context-free word completion well enough. merlin adds typing and other niceties, but those become less useful if they aren't "true" in the completion's context.
As suggested above, for identifier completion, I think it's a bad idea to ask for type-checking truth in the context of code editing. Not every of your editing operations makes your source type checkable. Failing to take that into account makes the tool less useful, it's eventual type checkability your after.
Daniel
(ignore last reference, I referenced wrong issue -_-)
In the same vein I notice that merlin won't allow me to complete the name of a recursive function if the rec
keyword is absent.
Again I think it's wrong. By refusing to do so you are interrupting my stream of thought which is about implementing a recursive function to solve a problem, not about the minutiae of having that rec
keyword at the right place which is an insignificant problem that can be fixed later compared to the one I'm trying to solve. This insignificant problem will be immediately highlighted in red at the next save when, having written my function, my brain will be ready for fixing insignificant errors.
Good editor assistance is not to refuse to complete that identifier. Good editor assistance would tell me on the next save "here it seems you are trying to implement a recursive function but you forgot the rec keyword, do you want me to introduce it for you ?".
In general merlin completion seems to be to the service of the typechecker rather than the (human) programmer and that feels completely wrong. It makes me bother about things at times when as a programmer trying to solve a problem I don't want to bother about but fix later.
Suppose you just defined a name in an
mli
file and then go into theml
file to implement it, it would be nice to be able to complete it by typinglet prefix...
and vice versa in anmli
file from a ml.