From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA03924; Tue, 6 Mar 2001 10:53:10 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA03897 for ; Tue, 6 Mar 2001 10:53:08 +0100 (MET) Received: from mta5.snfc21.pbi.net (mta5.snfc21.pbi.net [206.13.28.241]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f269r7b15105 for ; Tue, 6 Mar 2001 10:53:07 +0100 (MET) Received: from checkerlap.d6.com ([64.160.53.238]) by mta5.snfc21.pbi.net (Sun Internet Mail Server sims.3.5.2000.01.05.12.18.p9) with ESMTP id <0G9R00HAGS4NOI@mta5.snfc21.pbi.net> for caml-list@inria.fr; Tue, 6 Mar 2001 01:38:51 -0800 (PST) Date: Tue, 06 Mar 2001 01:29:57 -0800 From: Chris Hecker Subject: [Caml-list] create a closure in external C function? X-Sender: def6@shell16.ba.best.com To: caml-list@inria.fr Message-id: <4.3.2.7.2.20010306011427.03669de0@shell16.ba.best.com> MIME-version: 1.0 X-Mailer: QUALCOMM Windows Eudora Version 4.3.2 Content-type: text/plain; charset="us-ascii" Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I can't find any docs on this, except for a couple hints that it might be possible... I want to create a function and return it from an external C function: type ii = int -> int val f : int -> ii = "c_function" where c_function looks something like this: value c_function( value i ) { return Val_closure(&some_c_int_int_function); } Is this possible? The Closure_tag is not very well documented, but from tracing through the asm for some callbacks and passing closures to C functions, it appears that the first word is a pointer to the actual generated code for the caml function. So, if you wanted to make this work you'd have to return a pointer to a caml function that calls _caml_c_call, which isn't really documented either (and looks platform specific, although it seems to just be jumping to the address of the passed C function after setting things up). Any hope of getting this working? Is caml_c_call designed to be a C callable function on all platforms (it doesn't look like it, since it takes a parm in registers on x86, which is unusual)? Is the bytecode sitatution completely different (I assume so)? Chris ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr