Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] A few questions regarding the compiler
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Patrick M Doane <patrick@w...>
Subject: Re: [Caml-list] A few questions regarding the compiler
On Sun, 11 Nov 2001, Marcin 'Qrczak' Kowalczyk wrote:

> Sun, 11 Nov 2001 18:38:30 +0100, Xavier Leroy <xavier.leroy@inria.fr> pisze:
>
> > Not easily.  You could link with the toplevel and call
> > "Toploop.use_silently" to execute code from a file, suppressing
> > the output.
>
> I looked closer and realized that it's quite impossible to plug into
> toplevellib something other than the default Topmain, although it's
> very close to being possible.
>
> For example the Clflags module is not exported (i.e. clflags.cmi
> is not installed) so I can't set any options. Initialization is
> hardwired into Toploop.loop, but calling Toploop.loop is too much:
> it reads from stdin (which must be available to the program so it
> can't be /dev/null) and writes to stdout. Initializing by hand is
> not possible because the relevant modules are not exported.

See my implementation of Fort which works around some of these issues. For
example, initialization is also hardwired into "run_script" so we can it:

  let save_arg = Sys.argv.(0) in
  Sys.argv.(0) <- "__dummy";
  let ignore_formatter =
    Format.make_formatter (fun _ _ _ -> ()) (fun _ -> ()) in
  ignore (Toploop.run_script ignore_formatter "__dummy" Sys.argv);
  Sys.argv.(0) <- save_arg

> I don't want to have to compile a custom OCaml version - it should
> work with whatever is installed with OCaml. Unfortunately now it's
> impossible.

I agree that the top-level interface should be improved. I've been able to
find workarounds so far, but it sounds like you have some issues that
require some definite changes.

Another gripe of mine is that Topdirs.dir_load does not print good
diagnostic information when it fails, so in practice I create a dummy
script containing a single "#load" directive to get the error messages to
display properly.

Patrick

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr