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
Re: [Caml-list] Calling Ocaml from Python
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2004-04-29 (05:33)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Calling Ocaml from Python
On Thu, 2004-04-29 at 15:07, Max Powers wrote:
> >On Thu, 2004-04-29 at 13:49, skaller wrote:
> >
> >There is an Ocaml module in SWIG which may be useful to you.
> Hmmm, forgive me if I'm totally off base with this, but I thought that SWIG 
> was used to interface a C library to other languages.


>  I.e. I can use SWIG to 
> generate an interface to a c library so I can use that from Ocaml, rather 
> than generating an interface to expose Ocaml functions to a C (or other) 
> program. 

You can write a C wrapper for an Ocaml function in C,
and then wrap THAT using SWIG so you can call it from Python.

Writing C that wraps a simple function like

	parse_file: string -> ast

should be easy: string is the filename, and ast is 
a magical pointer to the parse tree. The wrapper would
make it a root of the Caml gc. 

You can probably do that now. Of course you won't
be able to use 'ast' to do anything, but at least
you can check you can invoke the parser on either
side of the interface without a core dump :D

John Skaller,
voice: 061-2-9660-0850, 
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language

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