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

Powerful ocaml.toplevel.mk #7

Closed
foretspaisibles opened this issue Sep 27, 2014 · 2 comments
Closed

Powerful ocaml.toplevel.mk #7

foretspaisibles opened this issue Sep 27, 2014 · 2 comments

Comments

@foretspaisibles
Copy link
Owner

We need a powerful ocaml.toplevel.mk modules that eases the following tasks:

  1. Create a toplevel that automatically adds some paths to the include directories.
  2. Create a toplevel that automatically opens some modules.
  3. Create a toplevel that automatically install some custom printers.
  4. Use the toplevel from other parts of the project, to run tests and scripts.

Points 1, 2 and 3 do not need to be solved purely in ocaml.toplevel.mk but it might be useful to define some cooperation guidelines between the toplevel custom code and ocaml.toplevel.mk.

The toplevel should work identically when it is installed and when it is run inside a developper's subshell (see bps.project.mk).


@foretspaisibles
Copy link
Owner Author

Using Toploop.execute_phrase to initialise the toplevel from the
function assigned to Toploop.toplevel_startup_hook does not work, it
seems that the environment is reset when exiting the hook. Here is an
example illustrating this behaviour:

let execute_toplevel_phrase s =
  let phrase =
    !Toploop.parse_toplevel_phrase (Lexing.from_string s)
  in
  if Toploop.execute_phrase true Format.std_formatter phrase then
    ()
  else
    failwith "execute_toplevel_phrase"

let bootstrap () =
  execute_toplevel_phrase "let zero = 0;;"

let _ =
  Toploop.toplevel_startup_hook := bootstrap

While the initialisation routine echoes a val zero : int = 0
message, using zero results in an error indicating that zero is
unbound. But in the toplevel, using the command bootstrap() results
in zero being bound to 0 as expected.

We therefore may choose to rely exclusively on initialisation files to configure the toplevel adequately. We need to initialise correctly the toplevel, wether it is used in without being installed or being installed.

@foretspaisibles
Copy link
Owner Author

The best way to provide this functionality is to prepare a corresponding initialisation file and ensuring it is read at starting time. To ease this, a target display-developer-dirs has been added to the ocaml.toplevel.mk file in 9c85461.

foretspaisibles added a commit that referenced this issue Jan 3, 2015
This routine is useful because it takes OBJDIR in account.

Closes #7
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