| Anonymous | Login | Signup for a new account | 2013-05-23 19:42 CEST | ![]() |
| Main | My View | View Issues | Change Log | Roadmap |
| View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||||
| ID | Project | Category | View Status | Date Submitted | Last Update | ||||||
| 0003938 | OCaml | OCaml general | public | 2005-12-29 10:24 | 2008-09-08 11:16 | ||||||
| Reporter | jroewen | ||||||||||
| Assigned To | |||||||||||
| Priority | normal | Severity | feature | Reproducibility | N/A | ||||||
| Status | acknowledged | Resolution | open | ||||||||
| Platform | OS | OS Version | |||||||||
| Product Version | |||||||||||
| Target Version | Fixed in Version | ||||||||||
| Summary | 0003938: Option to automatically open given modules, as is done for Pervasives. | ||||||||||
| 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. | ||||||||||
| Tags | No tags attached. | ||||||||||
| Attached Files | |||||||||||
Notes |
|
|
(0003467) jroewen (reporter) 2005-12-29 12:19 |
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"; driver/main_args.mli: 29: + val _open : string -> unit tools/ocamlcp.ml: 57: + let _open s = option_with_arg "-open" s utils/clflags.ml: 21: +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. |
|
(0004599) Yoric (reporter) 2008-09-08 11:16 |
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. |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 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 | |
| Copyright © 2000 - 2011 MantisBT Group |