caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Why are modules handled differently by the interpreter and the compiler
@ 2012-11-03 15:21 Alain Coste
  2012-11-03 15:34 ` Didier Cassirame
  2012-11-03 15:56 ` AW: " Gerd Stolpmann
  0 siblings, 2 replies; 10+ messages in thread
From: Alain Coste @ 2012-11-03 15:21 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 1510 bytes --]

Hello,
Back to a problem which I have always found annoying in OCaml. I hoped the version 4.0 would solve it, but it seams nothing changed..
While developping a project, It's interesting to use the interpreter (for test, debugging) AND the compiler (to have program run faster when everything goes wright).
Now, when the project is divided in several modules, each module being a structure written in a .ml file (with possibly a signature in a .mli file), you can't simply use the interpreter and the compiler on the same files.
The interpreter loads the modules with their names (say M), and you can refer to its identifiers with M.foo, in the standard way.
The compiler adds one level of "modularity", as it encapsulates the contents of the file with "module M ...end". So now its identiifers should be referenced as M.M.foo !!
I found two possible work-arounds to this :
   - comment out all my top-level decarations of module before compiling the files
            needs to be undone and redone every time I want to reuse the interpreter for testing after a change in the the program
   - copy all the files in one file and compile this unique file
            this process is easy to automatize, but I loose the advantages of separate compilation

Can somebody explain the rationale behind this behavior. Or, if this is only for historical and compatibility reasons, could it be possible to have an option "-please_don't_encapsulate" (or something shorter...) for the compiler ?

Alain Coste

[-- Attachment #2: Type: text/html, Size: 2460 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-11-05 19:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-03 15:21 [Caml-list] Why are modules handled differently by the interpreter and the compiler Alain Coste
2012-11-03 15:34 ` Didier Cassirame
2012-11-03 15:55   ` Didier Cassirame
2012-11-03 15:58     ` Didier Cassirame
2012-11-03 16:52     ` Alain Coste
2012-11-03 17:14       ` Gabriel Scherer
2012-11-03 15:56 ` AW: " Gerd Stolpmann
2012-11-05  2:30   ` Grégoire Henry
2012-11-05 11:23     ` AW: " Gerd Stolpmann
2012-11-05 19:53     ` Alain Coste

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).