| Anonymous | Login | Signup for a new account | 2013-05-26 07:25 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 | |||
| 0005411 | OCaml | OCaml general | public | 2011-11-30 10:47 | 2012-09-25 20:07 | |||
| Reporter | dim | |||||||
| Assigned To | frisch | |||||||
| Priority | normal | Severity | feature | Reproducibility | have not tried | |||
| Status | closed | Resolution | fixed | |||||
| Platform | OS | OS Version | ||||||
| Product Version | 3.12.1 | |||||||
| Target Version | Fixed in Version | |||||||
| Summary | 0005411: New directive for the toplevel: #load_rec | |||||||
| Description | This new directive loads the file given as argument and all cmos it depends on. When one want to load a cmo in the toplevel which depends on other cmos, it has to load them one by one in the right order. This directive does that automatically. | |||||||
| Tags | No tags attached. | |||||||
| Attached Files | ||||||||
Notes |
|
|
(0006270) frisch (developer) 2011-12-13 17:43 |
I believe the proposed patch does not work when the name of the module contains uppercase characters (because of the call to String.lowercase). From an implementation point of view, it would be cleaner to iterate through compunit.cu_reloc in load_file (in 'rec' mode) in order to load missing modules (and not waiting for an exception to pop up). That said, I'm not 100% convinced by the proposal: a module can be provided by a .cma file, and there is no easy way to know which one. Do you have a convincing argument in favor of your suggestion? What would be a typical use case? |
|
(0006273) dim (developer) 2011-12-13 18:08 |
> I believe the proposed patch does not work when the name of the module contains uppercase characters (because of the call to String.lowercase). Indeed. It is a typo, it should be String.uncapitalize. > That said, I'm not 100% convinced by the proposal: a module can be provided by a .cma file, and there is no easy way to know which one. Do you have a convincing argument in favor of your suggestion? What would be a typical use case? The typical use is the following: you have a project with a lot of modules and you want to test in the toplevel an internal function of one of them. First you load dependencies with #require, then you have to load all the cmos of you project needed by the function you want to test, and you have to load them in the right order. In general you do that: # load "a.cmo";; Error: Reference to undefined global `B' # load "b.cmo";; Error: Reference to undefined global `C' # load "c.cmo";; # load "b.cmo";; # load "a.cmo";; The goal of this directive is just to do this mechanical stuff automatically. |
|
(0006275) mehdi (reporter) 2011-12-13 18:47 |
You can also put these directives in a file (say "foo.ml") and then, in a toplevel, do “#use "foo.ml";;”. You'll need to resolve the dependencies once to start, and update the file when needed. You can also implement your proposal in a "foo.ml" and #use it. |
|
(0006276) frisch (developer) 2011-12-13 18:51 |
Ok, wish granted. I'm a little bit uneasy with the fact that the loading order of dependent .cmo files is not specified (and this can change the semantics), but I can see there are cases where this can be useful. Committed to the trunk (rev 11306). Can you try it? Note that the recursive behavior is only applied when .cmo files (not .cma) are loaded. |
|
(0006277) dim (developer) 2011-12-13 19:11 |
> Committed to the trunk (rev 11306). Can you try it? Yes, it works. Thanks. > Note that the recursive behavior is only applied when .cmo files (not .cma) are loaded. OK. By the way, i just noticed that load_file does not close the input channel in case an exception (other than Load_failed) is raised. So if for example "#load "a.cmo";;" fails because of a reference to an undefined global the file will be kept open. |
|
(0006288) frisch (developer) 2011-12-14 12:04 |
Thanks, I've fixed load_file to close the input channel in case of error (commit 11315). |
Issue History |
|||
| Date Modified | Username | Field | Change |
| 2011-11-30 10:47 | dim | New Issue | |
| 2011-11-30 10:47 | dim | File Added: dir-load_rec.diff | |
| 2011-12-13 17:43 | frisch | Note Added: 0006270 | |
| 2011-12-13 18:08 | dim | Note Added: 0006273 | |
| 2011-12-13 18:47 | mehdi | Note Added: 0006275 | |
| 2011-12-13 18:51 | frisch | Note Added: 0006276 | |
| 2011-12-13 18:51 | frisch | Assigned To | => frisch |
| 2011-12-13 18:51 | frisch | Status | new => assigned |
| 2011-12-13 18:52 | frisch | Status | assigned => feedback |
| 2011-12-13 19:11 | dim | Note Added: 0006277 | |
| 2011-12-13 19:11 | dim | Status | feedback => assigned |
| 2011-12-14 12:04 | frisch | Note Added: 0006288 | |
| 2011-12-14 12:04 | frisch | Status | assigned => resolved |
| 2011-12-14 12:04 | frisch | Resolution | open => fixed |
| 2012-09-25 20:07 | xleroy | Status | resolved => closed |
| Copyright © 2000 - 2011 MantisBT Group |