caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Chris Hecker <checker@d6.com>
To: qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk), caml-list@inria.fr
Subject: Re: [Caml-list] create a closure in external C function?
Date: Tue, 06 Mar 2001 14:56:51 -0800	[thread overview]
Message-ID: <4.3.2.7.2.20010306140915.03782b00@shell16.ba.best.com> (raw)
In-Reply-To: <slrn9aakto.vv1.qrczak@qrnik.zagroda>


>> You can pass a closure to a C function and apply it to arguments
>> with the callback.h library pretty easily.
>It's not enough to convert a closure to a C function pointer.
>For example to wrap C's qsort() in this interface:
>    ('a -> 'a -> int) -> 'a array -> unit

Right, but it's part of the solution.  The plan is to make it so you can do that automatically.  On the C side, we'll use the ffcall trampoline/vacall interface to pass qsort the pointer to a function that calls back the caml function with the right parms.  It's gonna be beautiful (or go down in flames, one of the two :).  There are only a couple loose ends to tie up and I'm confident we'll be able to get it working in its full insane generality.

You'll still want to use an interface generator for any permanent functions you want to hook because this is going to generate a bunch of code to loop over arguments at runtime and whatnot, but for dynalinking to dlls (or doing stuff like OpenGL extensions) it'll rule.  Hopefully it'll only be 20% or so slower than a direct external function call.

It's not going to handle records or polymorphism at first, of course (or even passing or returning closures when I first write it).  I've got a plan for handling records, but I need to understand polymorphism more before I can think about that (in fact, I can't do any real work on this for a couple weeks, but I'm trying to lay the groundwork).

I'm also a little terrified of making this play nice with the GC, but we'll blow up that bridge when we come to it.

Chris


-------------------
To unsubscribe, mail caml-list-request@inria.fr.  Archives: http://caml.inria.fr


  reply	other threads:[~2001-03-06 22:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-06  9:29 Chris Hecker
2001-03-06 10:50 ` Fabrice Le Fessant
2001-03-06 17:01 ` Xavier Leroy
2001-03-06 18:19   ` Chris Hecker
2001-03-07  3:23     ` Fergus Henderson
2001-03-06 18:58   ` Marcin 'Qrczak' Kowalczyk
2001-03-06 19:13     ` Chris Hecker
2001-03-06 21:16       ` Marcin 'Qrczak' Kowalczyk
2001-03-06 22:56         ` Chris Hecker [this message]
2001-03-07  0:22           ` Marcin 'Qrczak' Kowalczyk
2001-03-07  0:44             ` Chris Hecker
2001-03-07  8:49               ` Marcin 'Qrczak' Kowalczyk

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=4.3.2.7.2.20010306140915.03782b00@shell16.ba.best.com \
    --to=checker@d6.com \
    --cc=caml-list@inria.fr \
    --cc=qrczak@knm.org.pl \
    /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;
as well as URLs for NNTP newsgroup(s).