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 BAA23459; Wed, 7 Mar 2001 01:22:00 +0100 (MET) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA23470 for ; Wed, 7 Mar 2001 01:21:59 +0100 (MET) Received: from mail.mimuw.edu.pl (pm211.warszawa.cvx.ppp.tpnet.pl [213.76.108.211]) by nez-perce.inria.fr (8.11.1/8.10.0) with ESMTP id f270KkD28161 for ; Wed, 7 Mar 2001 01:20:47 +0100 (MET) Received: (from news@localhost) by mail.mimuw.edu.pl (PLD/8.9.3) id BAA03199 for caml-list@inria.fr; Wed, 7 Mar 2001 01:22:31 +0100 X-Authentication-Warning: qrnik.zagroda: news set sender to qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) using -f From: qrczak@knm.org.pl (Marcin 'Qrczak' Kowalczyk) Subject: Re: [Caml-list] create a closure in external C function? Date: 7 Mar 2001 00:22:27 GMT Organization: Klub Nieszkodliwych =?iso-8859-2?Q?Manjak=F3w?= Message-ID: References: <4.3.2.7.2.20010306011427.03669de0@shell16.ba.best.com> <20010306180128.B12522@pauillac.inria.fr> <4.3.2.7.2.20010306111106.0372b7d0@shell16.ba.best.com> <4.3.2.7.2.20010306140915.03782b00@shell16.ba.best.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 8bit X-Trace: qrnik.zagroda 983924547 3197 192.168.0.1 (7 Mar 2001 00:22:27 GMT) X-Complaints-To: news@qrnik.zagroda NNTP-Posting-Date: 7 Mar 2001 00:22:27 GMT User-Agent: slrn/0.9.6.3 (Linux) To: caml-list@inria.fr Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Tue, 06 Mar 2001 14:56:51 -0800, Chris Hecker pisze: > 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. I've just seen ffcall. callback is approximately what I wanted. trampoline+vacall is evil. It uses a global variable; this is not thread safe. callback seems to be better, but still more kludgy than I expected. I'm not sure if it's the right choice for OCaml; it should not be *that* ugly. Especially if you statically know types of arguments, which is the case I am talking about. Unfortunately it's very processor-dependent. I would like to have this functionality in OCaml's foreign function interface, without forcing to rely on an inconvenient third-party package. I'm not sure how it should look like, because OCaml has a different approach to FFI than Haskell: the OCaml<->C glue is in C, where for Haskell<->C the glue is in Haskell. So Haskell defines a mapping from Haskell function types involving primitive types to C types, and a special kind of declaration which defines converters from Haskell functions to C function pointers of particular types. The OCaml's approach would need to call the conversion from the C level, in which case the compiler has no chance of generating stubs tailored for a particular type but must offer a generic C interface with its own way to describe C types. -- __("< Marcin Kowalczyk * qrczak@knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTĘPCZA QRCZAK ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr