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
Install toplevel printers using [@@toplevel_printer]
#10559
Conversation
One issue I noticed while playing with this is that that the printer only takes effect after the first time the module (or rather, its
This is because the |
A second issue, when using
|
I'm highly in favor of the feature. I haven't looked at the implementation just yet. @nojb I don't remember this limitation in the utop implementation, is it there ? If it isn't, why ? |
I confess I am not a |
It turns out that in order to implement completion |
I agree it would be nice to have .cma libraries that auto-install printers when loaded in the toplevel REPL. However, I think attaching an attribute to the declaration of the printer function is not the best way to go about it, if only because .cmi files are loaded on demand. An example for an alternative design: extend the .cma file format (and the |
The problem with scripts is that they easily go uncompiled. I played with such a scheme in I think it's also nicer if these things can be contained to the compilation units they concern. So pushing what you propose a bit further what about:
This for a module
|
Actually if we only care about printers and not making other effects specially for the toplevel we could even eschew the special symbol and boil down the thing to 1. and maybe a new flag in
And that |
This seems like a simple solution that does not require any changes to the infrastructure. |
One issue is that the printer-registering machinery in the Toplevel needs to have access to the concrete type of the printer being installed, and
What about extending the |
It seems that's what @let-def does in https://github.com/let-def/autoprinter |
I would still like to have something like this, but the patch doesn't work in its current form. Closing. |
Following discussion in #10557, this PR is to discuss the patch proposed in #7770 written originally by @jeremiedimino to automatically install values annotated with
[@@toplevel_printer]
as toplevel printers.Fixes #7770