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

Alias based packs #23

Open
rgrinberg opened this issue Mar 5, 2016 · 4 comments
Open

Alias based packs #23

rgrinberg opened this issue Mar 5, 2016 · 4 comments

Comments

@rgrinberg
Copy link
Collaborator

omake supports building traditional packs with OCamlPackage but as you know, these are effectively deprecated since module aliases have been introduced.

It would be great if omake supported something very similar to OCamlPackage but used aliases under the hood.

cc'ing @camlspotter because he both uses omake and understands how aliases work as evident by https://github.com/camlspotter/caml-module-alias-link

However, I'd be happy to work on this as well if given some pointers.

@camlspotter
Copy link
Contributor

camlspotter commented Apr 29, 2016

So far, the simplest way to use -no-alias-deps is:

  • Use OCamlLibrary instead of OCamlPackage
  • -w -49
  • OCAMLFLAGS += -no-alias-deps
  • OCAMLDEPFLAGS += -as-map (and of course, use ocamldep with this option)

I have just ported one of my libraries (ppx_orakuda) from OCamlPackage to OCamlLibrary with this -no-alias-deps and it is pretty nice.

Only one downside is that you have to rename your modules to something which would not corride with other libraries, since they are no longer packed into a packed module. For examlpe regexp.ml => ppx_orakuda_regexp.ml.

It would be nice if we have a super OCamlPackage or OCamlLibrary which do everything above including the module renaming on the fly... It is possible but very hard, and I do not have any motivation to tackle it so far.

@gerdstolpmann
Copy link
Collaborator

As it is implemented currently, -no-alias-deps is highly experimental. If it was considered a regular language feature, packing would be re-implemented with it (or an alternative -alias-based-pack mechanism would be offered).

How could omake help in the current situation? The ingredients are (as described in section 7.13 of the OCaml manual):

  • set the flags as described by ocamlspotter
  • generate the pack module with the aliases to get the namespacing effect
  • rename the sources so that they all have a (hopefully) unique prefix

Omake can only implement the first two points. The third is still up to the user. There is also no way to automatically choose a unique prefix for the member modules (e.g. via a -module-prefix option of ocamlc/ocamlopt).

My opinion on that is: as long as it is experimental and not so well supported by the compiler, let's ignore it. The alternative (if you care about code size) is not to pack at all.

@rgrinberg
Copy link
Collaborator Author

@gerdstolpmann Why do you think that -no-alias-deps is experimental? Seems like it's been implemented for quite a while (4.02?) and has some serious users (Janestreet to name one example). In my opinion, it would have many more users if it wasn't so difficult to use due to weak support from build systems.

@gerdstolpmann
Copy link
Collaborator

This is just my interpretation of the status: it exposes implementation details to the user (even requires that the user takes them over partly). In my view this is just an attempt to figure out whether it would work at all like this. The real implemention would be to hide all the details from the user, and the interface would be largely the same as for -pack nowadays.

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

No branches or pull requests

4 participants
@rgrinberg @camlspotter @gerdstolpmann and others