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

#info directive #294

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

#info directive #294

wants to merge 5 commits into from

Conversation

kandu
Copy link
Collaborator

@kandu kandu commented Jul 26, 2019

This PR adds a depopt, ocp-index to utop. If utop is built when ocp-index is installed, a new directive, #infoof, will present.

This directive works similarly to #typeof. The symbol resolving and completion mechanism is based on the current Env of the Toploop. That is, if we type open String;; in utop, #infoof "concat" will still find out the very infomation of String.concat

Click to expand

image

kandu added 3 commits July 26, 2019 12:00
The lazy-evaluation feature causes LibIndex module of ocp-index to hang if
the Env.t of the Toploop changes. We can't #require or #load other
libraryies. To workaround it, we fork a clean room for ocp-index.
@kandu kandu requested review from a user and pmetzger July 26, 2019 07:20
@kandu kandu mentioned this pull request Jul 26, 2019
@pmetzger
Copy link
Member

pmetzger commented Jul 26, 2019

I have to say that as an English speaker I find "#infoof" amazingly hard to read. (I also wouldn't guess what it does from the name, the first parse that comes to mind is "in foof" and that's pretty incomprehensible...)

@bluddy
Copy link

bluddy commented Jul 26, 2019

Yeah this isn't a great name. #info is fine; #doc is fine; #info_of could work.

@pmetzger
Copy link
Member

I'd say "#info" or "#doc".

@kandu
Copy link
Collaborator Author

kandu commented Jul 27, 2019

Ha, at the first glance. I feel that the name is very funny. foof ʕoٹoʔ ʕ•̀ω•́ʔ

@kandu
Copy link
Collaborator Author

kandu commented Jul 27, 2019

I think #info is fine.

@pmetzger pmetzger changed the title #infoof directive #info directive Jul 28, 2019
@pmetzger
Copy link
Member

I've renamed the pull request btw.

@ghost
Copy link

ghost commented Jul 30, 2019

That's a nice feature :) BTW, I would make the dependency on ocp-index be a required one rather than an optional one. Optional dependencies always end up being annoying in the long run.

@kandu
Copy link
Collaborator Author

kandu commented Jul 31, 2019

The implementation of ocp-index seems not stable for now(we have to fork a clean room for it). I'd like to keep it as an optional dependency to observe for a period of time. When everything is stable enough, we then make it as a required dependency. Is this ok?

@pmetzger
Copy link
Member

I have no opinion on the optional vs. required dependency issue.

How do we decide when this is okay to merge?

@bluddy
Copy link

bluddy commented Jul 31, 2019

@diml I've seen negative opinions about optional dependencies, but what is the main objection against them?

@ghost
Copy link

ghost commented Aug 1, 2019

@kandu that seems reasonable yeah.

@pmetzger I'd suggest that someone test it on its machine, just to make sure nothing obvious was missed, and eyeball the code to make sure things seem reasonable. For instance that no unwanted dependency was added by accident or a rootkit was slipped in (just joking here, though we should definitely do it for new contributors).

Then I'd say it's good to merge. This looks like a feature that is worth having.

@bluddy the main source of pain is recompilation. When you install a new package, you have to recompile all already installed packages that have a depopts on this package plus all their reverse dependencies. For utop I guess it's probably not too bad as it doesn't have many reverse dependencies.

But in this case there is also something else: whenever you setup a new switch, you now have to remember to install both utop and ocp-index if you want all the features of utop.

@pmetzger
Copy link
Member

pmetzger commented Aug 1, 2019

It seems to me that requiring ocp-index as mandatory has only one defect, which is that sometimes it is broken when a new release comes out.

@kandu
Copy link
Collaborator Author

kandu commented Aug 1, 2019

yeah, considering about this, to keep it as an optional dependency is a good option since what you've just said implies we are confident that zed, lambda-term and utop will keep the pace with new ocaml releases better than ocp-index will do :) And once that happens, utop will be still installable without the presenting of #info directive temporarily.

@kandu
Copy link
Collaborator Author

kandu commented Aug 4, 2019

This feature is disabled on Windows since Unix.fork is not available on it.

By the way, are there any easy expressions in dune which I can use to define required libraries more flexibly? like:

(libraries
  ((and (= %{os_type} Unix) (= (system "opam var ocp-index:installed") "true"))
    ocp-index))

Only requires ocp-index as dependency when we are on Unix and ocp-index is installed.

@pmetzger
Copy link
Member

pmetzger commented Aug 4, 2019

@kandu Good question. I don't know. Perhaps you should ask the Dune maintainers?

@ghost
Copy link

ghost commented Aug 5, 2019

Not really, though there is a ticket about this.

What about using spawn? It's a portable and more efficient way of spawning sub-processes. Note that it's under the janestreet org, however it is developed on github as a normal open source project, so you can expect the API to be stable.

@kandu
Copy link
Collaborator Author

kandu commented Aug 5, 2019

There are two ways to use ocp-index.

  1. to invoke the ocp-index excutable every time when user types #info "something". So we can call Unix.create_process or spawn to invoke it. This works on all OSes, including Windows. But we'll always tolerate the lag, especially when inquiring from a big library like core_kernel.

  2. to use the LibIndex library, create and keep the index data permanently in a process memory. Module info is cached in the lazy-evaluation data structure when user re-inquire some info of the same library. But because of the implementation issuse, we have to workaround it, to fork a clean room for it or the CPU will hang. But since Unix.fork is not implemented on Windows, we have to disable this feature on Windows or we have to either create a standalone executable wrapping LibIndex or we add a new cmd-opt to utop to tell it to work in "ocp-index-server" mode and then spawn a child utop to inquire info. We now just simply disable it on Windows.

I think the second way is preferable, ocp-index developers will eventually fix the bug and we will not need to fork a clean room for it and thus it will work on all OSes. The lack of Windows support is temporary.

@kandu
Copy link
Collaborator Author

kandu commented Aug 5, 2019

Hi, @AltGr @Drup
The step-to-reproduce is quite obvious, Should I create a new issue in https://github.com/OCamlPro/ocp-index/ ?

@ghost
Copy link

ghost commented Aug 6, 2019

I see. Personally, I would recommend to fix ocp-index first. It means that we have to wait before making this feature available to users, but on the other hand when we release it both utop and ocp-index will be in a better state.

@AltGr
Copy link
Contributor

AltGr commented Aug 6, 2019

Wow, this looks great, thanks! @kandu, if you could open an issue as you proposed, that'd be very helpful and I'll look into it. :)

@kandu
Copy link
Collaborator Author

kandu commented Aug 6, 2019

Ah, thanks! here is the issue report OCamlPro/ocp-index#136

@Drup
Copy link
Member

Drup commented Aug 15, 2019

Great feature! Method 2 is clearly preferable, and libindex should be fairly easy to use. Let's try to beat ocp-index into shape so that everything works fine :p

@mimoo
Copy link

mimoo commented May 11, 2021

btw, why not show the doc information in the suggestion bar on the bottom? This is what bpython does for example.

@pmetzger
Copy link
Member

BTW, I note this has been stalled out for a long time. What do we need to do to get it moving?

@bbatsov
Copy link
Contributor

bbatsov commented Jul 19, 2022

@pmetzger I guess someone has to fix OCamlPro/ocp-index#136

@pmetzger
Copy link
Member

pmetzger commented Sep 8, 2022

What do we need to do to get this merged?

@emillon
Copy link
Collaborator

emillon commented Sep 8, 2022

I'm not familiar with the implementation of this PR, but if it just adds a new directive, I don't think it has to be maintained as part as utop. It can be implemented as something that when #require'd, will add the directive. Users can call utop -require ocpindex.top or add this to their dotfiles to do it automatically. Would that work for you?

@pmetzger
Copy link
Member

pmetzger commented Sep 8, 2022

Up to @kandu.

Copy link

@yawaramin yawaramin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a new dependency needed for this? Doesn't utop have access to the docstrings of various items like it has access to their type signatures?

@pmetzger
Copy link
Member

pmetzger commented May 7, 2023

I note that this is still hanging around; @kandu you should finish it.

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

Successfully merging this pull request may close these issues.

9 participants