So I guess that would mean ripping the Linux_ext module out of Core, right?<div><br></div><div>While I agree about keeping conditional code localized and small, I don't quite see why the right answer is to have zero tolerance for conditional compilation of OCaml.  Imagine that you have different APIs on different platforms that require non-trivially different logic.  Now you're wedded to the idea of having non-trivial code that compiles conditionally.  The only question is, will you write that code in C or in OCaml?  Given that choice, I usually choose OCaml...</div>
<div><br></div><div>Another way of dealing with some of these things is with runtime-tests that key-off of the platform, potentially using first-class modules.  i.e., you could have a value of the type:</div><div><br></div>
<div><font class="Apple-style-span" face="'courier new', monospace">val os : [ `Windows of (module Windows_specific_API)</font></div><div><font class="Apple-style-span" face="'courier new', monospace">         | `Linux   of (module Linux_specific_API)</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">         | `BSD     of (module BSD_specific_API)</font></div><div><font class="Apple-style-span" face="'courier new', monospace">         | `Posix   of (module Posix_specific_API) ]</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace"><br></font></div><div>The obvious downside is that it's a bit slower to dispatch your code, but if you're doing a system call, maybe that doesn't matter.  And it has the nice property that all of your OCaml code is type-checked all the time.  You would just need some conditional compilation that chose the value of `os` at compile-time.  The upside is that it gives you a way of writing cross-platform programs that take advantage of the extra functionality when it's present.</div>
<div><br></div><div>y<br><br><div class="gmail_quote">On Mon, Nov 21, 2011 at 10:22 PM, Stephen Weeks <span dir="ltr"><<a href="mailto:sweeks@janestreet.com">sweeks@janestreet.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
> Stephen, what do you think about Markus' proposal for how to organize<br>
> it?<br>
<br>
</div>I am highly skeptical of the approach of propagating Linux submodules and<br>
conditional compilation throughout the codebase.  I think it would be preferable<br>
to design a platform-agnostic interface at the OCaml/C boundary, implemented on<br>
the C side using platform-specific C files with minimal conditional compilation<br>
at the C level and no conditional compilation at the OCaml level.  Platforms<br>
that are unable to implement particular aspects of the interfaces should provide<br>
functions that raise exceptions.  Then all OCaml code compiles everywhere, and<br>
it one gets on each platform the maximum ability to run what is actually<br>
implemented.<br>
</blockquote></div><br></div>