From: John Max Skaller <skaller@ozemail.com.au>
To: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
Cc: Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Possible use for camlp4
Date: Thu, 30 May 2002 05:25:19 +1000 [thread overview]
Message-ID: <3CF52B1F.2050004@ozemail.com.au> (raw)
In-Reply-To: <20020527213326.F9870@verdot.inria.fr>
Daniel de Rauglaudre wrote:
>>Hmm.. can camlp4 generate C?
>>
>What do you mean by "generate C"? Can you specify, give examples?
>
Input:
CBINDING fred:int -> int = fred($1) ENDBINDING
output #1:
extern int fred_binding(int x) { return fred(x); } /* generated C
function */
output #2:
external fred:int ->int = "fred_binding"; (* ocaml stub *)
The idea is a file of hand written bindings which generate the C code
necessary to wrap a C library. There are two outputs: the C glue code
and the ocaml binding definitions.
The point is to use camlp4 to make it easier to write the C glue code,
by inventing some language syntax which knows about the garbage
collector, heap format, the macros needed to do all that, etc.
That is, the glue code isn't generated *automatically* from a C interface,
like with SWIG. Instead, you have to write the glue code by hand,
as you do now. The difference is that you write it in a slightly
higher level language than the ugly and error prone C/Ocaml macros
system. In addition, the 'simplified' way of using those macros is sometimes
very inefficient. [eg, making parameters and local variables gc roots
when there is no need]
Just as an example: the keyword 'interruptible' might mean
to use enter/leave blocking section macros.
That is: my suggestion is to design a language CamlCGlue,
which generates C code to bind ocaml to C libraries,
and implement it using camlp4.
BTW: this thought was prompted by the debate as to whether
camlp4 belongs in the standard distribution or not, and unrelated
discussion about building bindings to C libraries.
If there is one thing that Ocaml is perceived as needing more
than anything else for industrial use, it's bindings to more C libraries.
At present, writing them is very very expensive, and maintaining
them is an even worse problem if the target C library is evolving
eg GTK. So .. why not use ocamlp4 to help reduce the problem?
--
John Max Skaller, mailto:skaller@ozemail.com.au
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.
voice:61-2-9660-0850
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2002-05-29 19:25 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-05-25 3:45 [Caml-list] What about polymorphic methods? Alessandro Baretta
2002-05-25 3:55 ` Jacques Garrigue
2002-05-25 5:42 ` John Prevost
2002-05-27 19:10 ` Alessandro Baretta
2002-05-27 18:22 ` John Max Skaller
2002-05-30 0:02 ` Alessandro Baretta
2002-05-27 18:27 ` [Caml-list] Possible use for camlp4 John Max Skaller
2002-05-27 18:35 ` Alexander V. Voinov
2002-05-27 19:33 ` Daniel de Rauglaudre
2002-05-29 19:25 ` John Max Skaller [this message]
2002-05-30 2:42 ` Jacques Garrigue
2002-05-30 8:15 ` Daniel de Rauglaudre
2002-05-27 19:37 ` Daniel de Rauglaudre
2002-06-02 8:34 ` [Caml-list] What about polymorphic methods? Lauri Alanko
2002-06-03 23:57 ` Jacques Garrigue
2002-06-08 9:52 ` [Caml-list] What about polymorphic methods Alessandro Baretta
2002-06-10 10:13 ` Jacques Garrigue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3CF52B1F.2050004@ozemail.com.au \
--to=skaller@ozemail.com.au \
--cc=caml-list@inria.fr \
--cc=daniel.de_rauglaudre@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox