|Anonymous | Login | Signup for a new account||2014-10-31 09:37 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0003938||OCaml||OCaml general||public||2005-12-29 10:24||2013-09-03 17:00|
|Target Version||Fixed in Version|
|Summary||0003938: Option to automatically open given modules, as is done for Pervasives.|
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.
I don't know how to do a diff, so here's my breakdown of implementing this option again ocaml 3.08.4:
+/- let initial = try
+ 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
+ let _open s = open_libs := s :: !open_libs
+ val _open : string -> unit
+ "-open", Arg.String F._open,
+ "<module> Add <module> to the list of automatically opened modules";
+ val _open : string -> unit
+ let _open s = option_with_arg "-open" s
+and open_libs = ref ( : string list) (* -open *)
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.
|2005-12-29 10:24||jroewen||New Issue|
|2005-12-29 12:19||jroewen||Note Added: 0003467|
|2006-01-05 14:20||doligez||Status||new => acknowledged|
|2008-09-08 11:16||Yoric||Note Added: 0004599|
|2013-09-03 17:00||doligez||Tag Attached: patch|
|Copyright © 2000 - 2011 MantisBT Group|