You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 3938 Reporter: jroewen Assigned to:@mshinwell Status: resolved (set by @mshinwell on 2016-12-06T21:53:32Z) Resolution: fixed Priority: normal Severity: feature Category: ~DO NOT USE (was: OCaml general) Tags: patch
Bug description
Hi,
I'd like to see some sort of option to the ocaml compiler to have it automatically 'open' given modules so that values in them are automatically accessible.
Something like -auto-open IO.
The reason for this is that for Desert Spring-Time (DST) to be able to provide some sort of API compatibility with standard O'Caml library, I'd need to be able to have one or two modules automatically opened.
This is because implementing things like IO in ocaml require to break Pervasives API (moving IO out), otherwise to develop the IO module, you end up with the problem of a) not being able to USE pervasives, and b) since pervasives depends on the new module, not being able to use the standard library itself!
So, if say print_endline is moved to IO module for example, all programs compiled for DST will need to add an "open IO" line to each module that uses it. This is not a good thing IMO, as it special cases programs to DST.
If instead, we could add "-auto-open IO" to some ocaml flags in a Makefile for example, this requirement would disappear, essentially providing API compatability between standard ocaml programs on other platforms and DST.
The text was updated successfully, but these errors were encountered:
I don't know how to do a diff, so here's my breakdown of implementing this option again ocaml 3.08.4:
driver/compile.ml:
44:
+/- let initial = try
50:
in
List.fold_left (fun a b -> try Env.open_pers_signature b a with Not_found -> fatal_error (Printf.sprintf "cannot open cmi for %s" b)) initial !Clflags.open_libs
driver/main.ml:
98:
let _open s = open_libs := s :: !open_libs
driver/main_args.ml:
29:
val _open : string -> unit
84:
"-open", Arg.String F._open,
"<module> Add <module> to the list of automatically opened modules";
As you can see, it's a fairly simple addition, though I suppose it could be abused as an alternative to using open, and would at the very least break ocamldep from finding correct dependencies.
This feature would be quite nice for Batteries Included, too, although for different reasons: where DST wishes to replace Pervasives with something smaller, we'd like to replace it with something bigger, without altering ocamlc.
At the moment, the only manner I can think of auto-opening a module is to pre-process every single source file and add "open Foo" at the first line. It's a bit wasteful.
Original bug ID: 3938
Reporter: jroewen
Assigned to: @mshinwell
Status: resolved (set by @mshinwell on 2016-12-06T21:53:32Z)
Resolution: fixed
Priority: normal
Severity: feature
Category: ~DO NOT USE (was: OCaml general)
Tags: patch
Bug description
Hi,
I'd like to see some sort of option to the ocaml compiler to have it automatically 'open' given modules so that values in them are automatically accessible.
Something like -auto-open IO.
The reason for this is that for Desert Spring-Time (DST) to be able to provide some sort of API compatibility with standard O'Caml library, I'd need to be able to have one or two modules automatically opened.
This is because implementing things like IO in ocaml require to break Pervasives API (moving IO out), otherwise to develop the IO module, you end up with the problem of a) not being able to USE pervasives, and b) since pervasives depends on the new module, not being able to use the standard library itself!
So, if say print_endline is moved to IO module for example, all programs compiled for DST will need to add an "open IO" line to each module that uses it. This is not a good thing IMO, as it special cases programs to DST.
If instead, we could add "-auto-open IO" to some ocaml flags in a Makefile for example, this requirement would disappear, essentially providing API compatability between standard ocaml programs on other platforms and DST.
The text was updated successfully, but these errors were encountered: