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: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] A few questions regarding the compiler
> > In 3.03 alpha and in the forthcoming 3.03, additional "hooks" were
> > added to the toplevel so that it can call user-provided functions for
> > displaying evaluation results, including uncaught exceptions.  The
> > Camlp4 preprocessor makes good use of this new feature.
> 
> Only toplevel? I would like to have it in standalone executables.

For standalone executables, it is very easy to wrap your generated
program in a catch-all "try...with" construct, and print the escaping
exception as you see fit.

> I don't see how Camlp4 could help. The compiler is not written in
> OCaml, it only generates OCaml output.

Camlp4 (among other features) provides an easy way to construct OCaml
abstract syntax trees and have then compiled or executed by the OCaml
compilers or toplevel.  It exploits a number of hooks in the compilers
and toplevel to achieve fairly tight integration with them.  So, I'm
pretty sure it could help, provided your compiler is written in OCaml
indeed.

> [toplevel interface not doing what you want]
> I don't want to have to compile a custom OCaml version - it should
> work with whatever is installed with OCaml.

Methinks you're asking for too much here :-)

> Another question. Low-level libraries for my language contain many
> embedded OCaml snippets written by hand, so they often contain errors.
> Is it possible to tell the OCaml compiler about original source
> positions for parts of the program, so it reports them in error
> messages? I mean like '# line_no "filename"' in cpp. Maybe Camlp4
> could help?

The ocamlc and ocamlopt compilers honor '# lineno "filename"'
directives.

> Yet another question. OCaml doesn't accept an identifier as the
> rhs of let rec (an identifier defined earlier). Why? I had to make
> a little workaround to not generate such bindings. I guess it's the
> only difference between "what is accepted in let rec" and "what allows
> generalization of free type variables"?

IIRC, the reason was that this offered no increase in expressive
power, yet would require a nasty special case in the compilation
scheme for "let rec" definitions.

- Xavier Leroy
-------------------
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