On 12/11/07, Andrew Ross <andrewross@...> wrote:
> Dear Hezekiah,
> It is great that you are working on plplot. We always welcome new
> I must admit that I am have minimal experience with OCaml, but I thought
> I would try it out. It built fine, but I'm unsure how to run the
> example. Perhaps you could include some details?
> At some stage it would be good to integrate OCaml bindings into the
> main plplot source. It sounds as if it would be good for you to discuss
> with the author of the previous swig-based bindings which approach is
> better and to combine efforts to work on the better approach.
> In general our approach has been to develop bindings which can be
> generated automatically wherever possible. This minimises the work for
> the core developers whenever adding new functionality and generally
> provides a more robust and consistent approach. We already use swig for
> the java and python bindings so there is some appeal in using this for
> OCaml too. What are the advantages of camlidl over swig in this respect?
> To be integrated within plplot the bindings will have to be built using
> CMake. If you have a working make file though the core developers are
> likely to be able to help you with this, so don't let this put you off.
> Do keep working on this.
Thank you for the positive feedback. I am quite happy to hear that it
actually builds for someone else!
For the included example, the following should work to compile it to a
$ ocamlfind ocamlc -package plplot -linkpkg -o x11 x11.ml
That is assuming you have compiled and installed the plplot bindings
using make libinstall. If not,
$ ocamlc -I ../ plplot.cma -o x11 x11.ml
should work once the library is built, if you run that from the
I do intend to get in touch with the author of the SWIG-based
bindings, but he has indicated previously on the OCaml mailing list
that he will not have time to maintain them.
My main reasons for using camlidl over SWIG are:
a) I have also used SWIG to create HDF4 library bindings for OCaml, so
I have some experience with it
b) The process is relatively easy - I take a slightly modified
plplot.h file, and preprocess it with a script I wrote. The output
feeds in to camlidl which generates the binding code. This is quite
similar, as I understand it, to how a SWIG binding would work.
c) camlidl seems to produce much more lightweight bindings than SWIG.
Looking through the existing SWIG-based OCaml bindings there are a
large number of extra type wrappers which are not needed when using
camlidl. There may be ways around this in SWIG which I do not know
With that said, I am quite open to suggestions. The binding code I
announced was the result of ~3 evenings of work, so it was not a huge
effort thanks to (relative) ease of using OCaml's C interface. I
would be happy to bring this in to the main plplot source tree and
maintain it. I still have several things which need to be documented,
such as callbacks - which are available for (I think) most of the
functions which use them, but they are setup differently.
Should the rest of this discussion continue on plplot-devel?
Thank you again for the feedback.
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science