From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id DFEE2BC54 for ; Sat, 9 Jan 2010 01:11:55 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AugBAJ5YR0tV2gB4mWdsb2JhbACDXpd9AQEBAQEICwoHE6xejQeBK4IuVgSJJg X-IronPort-AV: E=Sophos;i="4.49,244,1262559600"; d="scan'208";a="41308971" Received: from emailfrontal1.citycable.ch ([85.218.0.120]) by mail3-smtp-sop.national.inria.fr with SMTP; 09 Jan 2010 01:11:55 +0100 Received: from [192.168.0.12] (unknown [85.218.92.99]) (Authenticated sender: guillaume.yziquel@citycable.ch) by emailfrontal1.citycable.ch (Postfix) with ESMTPA id EE24812C098; Sat, 9 Jan 2010 01:11:53 +0100 (CET) Message-ID: <4B47C9BE.4060309@citycable.ch> Date: Sat, 09 Jan 2010 01:11:42 +0100 From: Guillaume Yziquel Reply-To: guillaume.yziquel@citycable.ch User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090707) MIME-Version: 1.0 To: Basile STARYNKEVITCH Cc: Damien Doligez , caml-list List Subject: Re: [Caml-list] problem creating .cma library References: <56670.41.177.16.252.1262195331.squirrel@41.177.16.252> <4B3BE288.4030701@citycable.ch> <3EE07409-9559-4B91-BA3E-8787D1378275@inria.fr> <4B47C201.7090201@citycable.ch> <4B47C59C.9080505@starynkevitch.net> In-Reply-To: <4B47C59C.9080505@starynkevitch.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; guillaume:01 guillaume:01 basile:01 camlparam:01 camlreturn:01 ocaml:01 damien:01 ocaml:01 camlparam:01 camlreturn:01 bindings:01 garbage:01 wrote:01 abstract:01 caml-list:01 Basile STARYNKEVITCH a =C3=A9crit : >> >> Why do these functions not follow the usual CAMLparam/CAMLreturn macro= =20 >> stuff? >=20 > Because they are written by the Ocaml guys (Damien knows really well th= e=20 > Ocaml garbage collector; he wrote it). And also, because these=20 > particular functions do not do any allocation of Ocaml values (either=20 > directly or indirectly). So, no allocation of OCaml values (or in place modification, either, I=20 guess) implies no need for CAMLparam/CAMLreturn stuff? > My advice for people coding C code for ocaml is the following: >=20 > 1. *always* use the CAMLparam/CAMLreturn/... macros. >=20 > 2. if you dare not using them for some very few functions (because they= =20 > don't allocate, ...) add a big fat comment with a warning inside. >=20 > Regards I want to understand them so that I can abstract away in some other file=20 / .so, some rather usual constructs involving OCaml structures. I think=20 it is smarter to take some time doing this, with detailed comments all=20 over, than repeating the same mistakes over and over (or worse:=20 wondering if you made mistakes) when doing C bindings. All the best, --=20 Guillaume Yziquel http://yziquel.homelinux.org/