|Anonymous | Login | Signup for a new account||2013-12-12 03:13 CET|
|Main | My View | View Issues | Change Log | Roadmap|
|View Issue Details|
|ID||Project||Category||View Status||Date Submitted||Last Update|
|0005411||OCaml||OCaml general||public||2011-11-30 10:47||2013-08-30 22:43|
|Priority||normal||Severity||feature||Reproducibility||have not tried|
|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||dir-load_rec.diff [^] (1,719 bytes) 2011-11-30 10:47 [Show Content]|
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?
> 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.
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.
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.
> 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.
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.
|Thanks, I've fixed load_file to close the input channel in case of error (commit 11315).|
|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|
|2013-08-30 22:43||doligez||Relationship added||duplicate of 0001816|
|Copyright © 2000 - 2011 MantisBT Group|