Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] How to avoid compiling some code (like #ifdef in C)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David MENTRE <dmentre@l...>
Subject: Re: [Caml-list] How to avoid compiling some code (like #ifdef in C)
Hello Xavier,

Xavier Leroy <> writes:

> With ocamlopt, that code is eliminated as part of constant
> propagation.

Thank you to confirm my guess.

>> Does anybody see a better approach to do such a thing?

> Whether this is a "better" approach is open to debate.  With a
> preprocessor, you can remove not just code for expressions, but also
> other kind of code, e.g. code for the toplevel binding "let a() = ...".
> So, you get more flexibility, but at the expense of less static
> checking.  In particular, code that is #ifdef-ed out is not
> type-checked, while it is type-checked in your solution above.

I'm personally find that static checking is very useful. So, for my own
issue, the approach I proposed is "better". It allows me to be sure that
all automatics tests will always at least compile. And it works on
O'Caml 3.04 available in my old debian 3.0.

But I'll keep in my mind the two other approaches. 

Thank you for your answer,
 David Mentré <>
 GnuPG key fingerprint: A7CD 7357 3EC4 1163 745B  7FD3 FB3E AD7C 2A18 BE9E

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: