From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 6E085BB9C for ; Thu, 19 Jan 2006 13:13:43 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0JCDgot008698 for ; Thu, 19 Jan 2006 13:13:43 +0100 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 NAA04926 for ; Thu, 19 Jan 2006 13:13:42 +0100 (MET) Received: from mail.physik.uni-muenchen.de (mail.physik.uni-muenchen.de [192.54.42.129]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0JCDfJS008691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 19 Jan 2006 13:13:42 +0100 Received: from localhost (unknown [127.0.0.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id 6F71820013; Thu, 19 Jan 2006 13:13:41 +0100 (CET) Received: from mail.physik.uni-muenchen.de ([127.0.0.1]) by localhost (mail.physik.uni-muenchen.de [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 11498-01-36; Thu, 19 Jan 2006 13:13:41 +0100 (CET) Received: from mailhost.cip.physik.uni-muenchen.de (kaiser.cip.physik.uni-muenchen.de [141.84.136.1]) by mail.physik.uni-muenchen.de (Postfix) with ESMTP id 568232000F; Thu, 19 Jan 2006 13:13:41 +0100 (CET) Received: from aso.cip.physik.uni-muenchen.de (guffert.cip.physik.uni-muenchen.de [141.84.136.24]) by mailhost.cip.physik.uni-muenchen.de (Postfix) with ESMTP id C941926E87; Thu, 19 Jan 2006 13:13:40 +0100 (CET) Received: by aso.cip.physik.uni-muenchen.de (Postfix, from userid 3092) id A51AF783F3; Thu, 19 Jan 2006 13:13:40 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by aso.cip.physik.uni-muenchen.de (Postfix) with ESMTP id F299D80432; Thu, 19 Jan 2006 13:13:39 +0100 (CET) Date: Thu, 19 Jan 2006 13:13:39 +0100 (CET) From: Thomas Fischbacher To: Jacques Garrigue Cc: caml-list@inria.fr Subject: Re: [Caml-list] C interface style question In-Reply-To: <20060119.093955.97297811.garrigue@math.nagoya-u.ac.jp> Message-ID: References: <20060119.093955.97297811.garrigue@math.nagoya-u.ac.jp> X-BOFH: Daemons did it MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: amavisd-new at physik.uni-muenchen.de X-Miltered: at concorde with ID 43CF8276.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 43CF8275.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 allocations:01 bool:01 allocations:01 ocaml:01 cip:98 cip:98 lambda:01 lambda:01 wrote:01 behaviour:01 int:01 jacques:01 debian:02 parameter:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Thu, 19 Jan 2006, Jacques Garrigue wrote: > Registration is required to have the GC properly update the values. > The GC may be called by any allocation. Just by allocations in the local C code? Is this (and will this always be) a guaranteed property? How about future extensions and multithreading? > So it is only safe not to register a parameter (or a variable) in any > of the following 4 cases. > 1) you know that it can only hold a non-pointer value (int, bool, ...) > (i.e. the GC has nothing to update) > 2) there are no allocations in your function > 3) the parameter is not accessed after the first allocation > 4) for a new variable whose contents is returned, there is no > allocation between the setting of the variable and return. > > (1) and (2) are relatively easy to see, but (3) and (4) are a bit > trickier (particularly with side-effecting expressions), so > it is not a bad idea to register more parameters than strictly > necessary. Can I take this as an official position of the OCaml team on the behaviour of the C interface? -- regards, tf@cip.physik.uni-muenchen.de (o_ Thomas Fischbacher - http://www.cip.physik.uni-muenchen.de/~tf //\ (lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y) V_/_ (if (= x 0) y (g g (- x 1) (* x y)))) n 1)) (Debian GNU)