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 PAA14128; Fri, 27 Jun 2003 15:14:03 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 PAA13476 for ; Fri, 27 Jun 2003 15:14:02 +0200 (MET DST) Received: from post.kis.ru (post.kis.ru [195.98.32.206]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h5RDE1f21762 for ; Fri, 27 Jun 2003 15:14:01 +0200 (MET DST) Received: from [195.98.54.162] (HELO heaven.merann.ru) by post.kis.ru (CommuniGate Pro SMTP 4.0.6) with ESMTP id 2996896; Fri, 27 Jun 2003 17:14:01 +0400 Date: Fri, 27 Jun 2003 17:14:14 +0400 From: Mikhail Fedotov X-Mailer: The Bat! (v1.62r) Reply-To: Mikhail Fedotov X-Priority: 3 (Normal) Message-ID: <1635699383.20030627171414@kittown.com> To: art yerkes CC: Jean-Baptiste.Rouquier@inrialpes.fr, caml-list@inria.fr Subject: Re[4]: [Caml-list] interfacing C and OCaml In-Reply-To: <20030627075713.5791e800.ayerkes@on-demand-tech.com> References: <003001c33c17$343a0d80$355afac1@zofo> <54997465.20030627092459@kittown.com> <015e01c33c86$e06b79d0$7115c7c2@inrialpes.fr> <21255847.20030627125956@kittown.com> <20030627075713.5791e800.ayerkes@on-demand-tech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; caml-list:01 interfacing:01 lacks:01 camlprim:01 camlextern:01 dlls:01 alloc:01 camlparam:01 camllocal:01 val:01 passing:01 ocaml:01 caml:01 collector:02 unit:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello art, Friday, June 27, 2003, 4:57:13 PM, you wrote: >> Sorry, I've made a mistake myself. I've been talking mostly about "void" vs "value" >> issue in your examples, but this is already addressed in the manual by stating that >> the primitive function must return value. The documentation lacks introduction into >> the macroses "CAMLprim", "CAMLextern" etc, but they are not strictly required now >> if you are not dealing with Windows DLLs. ay> In my experience, it's completely safe to use the macros no matter where the ay> code is called from. You can omit them only when that would be safe, (i.e. ay> you don't allocate anything into the caml heap). You can get away with not ay> being nice to the GC only when you don't do anything that can trigger the ay> collector. This means that if you do any alloc, alloc_tuple, copy_string, ay> etc., then you must use them. It's not only for windows DLLs. Hmpf. I've made one more mistake by not being specific enough. You are talking about the CAMLparam/CAMLlocal macroses, and I'm talking about CAMLprim/CAMLextern macroses; those that I'm talking about are used as a prefix to a function name/type, not inside the body. If you have a "unit"-type function, you still need it to have a return value of type "value" with the value "Val_unit". This was en error in the first example if you would want to export that function to OCaml. If you don't use CAMLprim macroses you are introducing the risk that you code will need to be changed for someone to use. BTW, if you are calling one C function from another one with passing or returning values, you can escape from the need to use CAMLparam/CAMLlocal by passing a pointer to the values that are already CAMLparam-ed in the calling function, i.e. use "value*" type for function parameters for the functions that you don't need to export. -- Best regards, Mikhail mailto:mikhail@kittown.com ------------------- 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