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 AAA20856; Fri, 1 Jun 2001 00:59:36 +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 AAA20793 for ; Fri, 1 Jun 2001 00:59:34 +0200 (MET DST) Received: from mail12.speakeasy.net (mail12.speakeasy.net [216.254.0.212]) by nez-perce.inria.fr (8.11.1/8.10.0) with SMTP id f4VMxXb01643 for ; Fri, 1 Jun 2001 00:59:33 +0200 (MET DST) Received: (qmail 43524 invoked from network); 31 May 2001 22:59:32 -0000 Received: from unknown (HELO w2kpro) ([64.81.246.34]) (envelope-sender ) by mail12.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 31 May 2001 22:59:32 -0000 Message-ID: <00ff01c0ea25$68d716f0$22f65140@w2kpro> From: "Harry Chomsky" To: "Daniel de Rauglaudre" Cc: "Caml list" References: <00c301c0ea11$17a38570$22f65140@w2kpro> <20010601001301.A11836@verdot.inria.fr> Subject: Re: [Caml-list] Win32 API Date: Thu, 31 May 2001 15:59:55 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk > When you > call an OCaml alloc function, all your variables of type "value" may > point to wrong places. OK, I think I'm understanding this better now. So if a C function does all of its work using simple macros like Val_int then it's ok, but if it does anything that might cause the OCaml runtime to allocate memory, then it has to use the CAMLparam and CAMLreturn macros as described in the documentation. Is that right? Now I understand also why the naming conventions differ so radically between e.g. Val_int and copy_int32. Clearly the former just manipulates bits while the latter allocates memory. I had thought this was an insignificant distinction, so when I wrote functions like copy_int32 I named them Val_handle etc. I thought this made the code read more easily. But I see now why the distinction matters. I will go through my existing code to make it use the CAML* macros where necessary and rename the Val_* functions to copy_*. I'll write to the list again when I have posted these modifications. (To the writers of the [mostly superb] documentation: The rules listed in "Living in harmony with the garbage collector" are very clear, but most of the sample C code in the other sections of the chapter don't follow the rules. Perhaps the documentation could explain not just how to follow the rules but also *when* to follow them, and why they are ignored in those samples. Thanks!) ------------------- To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr