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

Officially add a Directives module to eschew toplevel directives syntax #13057

Open
ysalmon opened this issue Mar 28, 2024 · 0 comments
Open

Comments

@ysalmon
Copy link

ysalmon commented Mar 28, 2024

After upgrading to 5.1.1, I stumbled on the problem mentioned in #11979 : my ocamlinit was using Topdirs before #use "topfind".

This led me to realise that the Topdirs module I had been using to do things like let _ = Topdirs.dir_directory ("K:\\Applications_INFO\\OCaml\\supports\\" ^ Sys.ocaml_version) (very useful to provide to students in a lab where, unfortunately, not all computers have the same exact version of OCaml) is not "officially" available to users and subject to change.

However, I believe that using Topdirs functions (and so on) is better than using the toplevel directives that they implement :

  • they are more powerful (it is not possible to use a variable in a #directory, for example) ;
  • they do not require introducing a special syntax to new users, especially the dreaded ;;, and therefore also avoid confusions.

Since I understand the need for Topdirs and others to remain tweakable by the OCaml team, I suggest that in addition to the traditional #directive syntax (for the sake of compatibility), a new, user-faced OCaml module be added to the standard library as an interface, say Directives or Toplevel, and be the preferred way to manipulate the toplevel in the OCaml manual.

This would also allow to maintain conceptual compatibility with existing directives : eg. Topdirs.dir_load is not a drop-in replacement for #load, because one needs to say eg. Topdirs.dir_load Format.std_formatter somefile, but we could have a Directives.load that would behave exactly like #load.

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

1 participant