English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Turning off type-checking
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2002-05-14 (14:33)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: [Caml-list] Turning off type-checking
From: Markus Mottl <markus@oefai.at>

> people have always kept telling me that I have perverse needs, but that's
> the way it is: I (ab)use OCaml for interpreting models learnt by a machine
> learning system. The problem is that such models may require hundreds
> of thousand lines of OCaml-code including absolutely mad amounts of
> pattern-matches on and constructions of values of sum- and product type.
> Needless to say that I get into trouble when I actually want to interpret
> or compile these models to evaluate them on new data. Type checking just
> takes an awful amount of time, in fact much longer than the learning
> algorithm needs for model generation...
> It would be really nice if there were some command-line flag for the
> OCaml-compilers which turns off every check that is not required under the
> assumption that the given OCaml-code is (type) correct as is guaranteed in
> my case. Would this be easily possible? What else could I do to reduce the
> amount of work the OCaml-compiler has to do? Insert Obj.magic everywhere?

Unfortunately, the ocaml compiler is itself dependant on type
information.  Compilation of pattern-matching in particular is tightly
integrated with the type checker. So you cannot turn off type
checking, lest you get invalid code.

One thing you might want to try is to write your own interpreter for
your subset of ocaml. According to the code snippets you posted, it is
restricted enough, so that should be easy. Then you can experiment
without compiling, and compile later if you really need to. Note that
with some tricks your interpreter can share data representation with
ocaml, so that your functions could be called directly from ocaml
(with a bit of magic, of course).

As long as your type are not really huge (like in Alain's example),
and you are not using subtyping, I don't think that there is much room
for improvement in the compiler.  This said, we find a complexity bug
once in a while. One of them was quite serious: type checking was done
twice for arguments in applications. Usually you won't notice it, but
if you have an application inside an argument inside an
argument... this was exponential! Unfortunately I don't remember
whether this was corrected before or after 3.04.


Jacques Garrigue
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners