Hi Benjamin,
On 03/05/2010 15:46, Sylvain Le Gall wrote:
> On 03-05-2010, Benjamin Pierce<bcpierce@cis.upenn.edu> wrote:
>> Is anybody out there developing code in the common subset of OCaml and
>> F# so that it works with both compilers / libraries? I'd be very
>> interested in hearing about the feasibility of this arrangement...
>>
>
> There was a series of blog posts by CoherentPDF on
> http://planet.ocamlcore.org 1 year ago.
>
> Here is one of them:
> http://coherentpdf.com/blog/?p=10
>
> Browse their archives to have more:
> http://www.coherentpdf.com/news-archive.html
The current release of CamlPDF does this, and it's about 15000 lines of
Ocaml / F#.
http://www.coherentpdf.com/ocaml-libraries.html
You just have the occasional thing like this:
let digest =
(*IF-OCAML*)
Digest.string
(*ENDIF-OCAML*)
(*i*)(*F#
function s ->
let hasher = System.Security.Cryptography.MD5.Create () in
string_of_int_array (intarray_of_bytearray (hasher.ComputeHash
(bytearray_of_string s)))
F#*)(*i*)
to account for the difference in standard libraries. And a little bit of
messing around with the different syntax, for example writing
(!x).y
instead of !x.y
And you can't use labeled arguments or polymorphic variants.
But it's perfectly feasible. I converted said 15000 lines of code in a
few days.
Cheers,
--
John Whitington
Director, Coherent Graphics Ltd
http://www.coherentpdf.com/