From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 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 5B4C1BC0A for ; Fri, 16 Feb 2007 20:19:04 +0100 (CET) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.174]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1GJJ3SM022047 for ; Fri, 16 Feb 2007 20:19:03 +0100 Received: by ug-out-1314.google.com with SMTP id k3so222951ugf for ; Fri, 16 Feb 2007 11:19:03 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:reply-to:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:from; b=mkPOCz4W0RISG/CYYLxuCQTVgY7OvdCmKyvtsFQ7DDT//kKP93XSlqAKF24d1/dbiUAQRS7hxmZVi1bh5VAhGBQA8U9SuVxqgO/eyFdXwy7kzst+WmW2pbSAUtSCVVHJppZqOkQxh2csj7Uo64dGrpXAWekJl8WLz7+7Jt3JUGg= Received: by 10.66.244.11 with SMTP id r11mr3314564ugh.1171653543381; Fri, 16 Feb 2007 11:19:03 -0800 (PST) Received: from ?192.168.1.10? ( [84.98.78.95]) by mx.google.com with ESMTP id j2sm3938028ugf.2007.02.16.11.19.01; Fri, 16 Feb 2007 11:19:02 -0800 (PST) Message-ID: <45D603A4.7080500@laposte.net> Date: Fri, 16 Feb 2007 20:19:00 +0100 Reply-To: matthieu.dubuget@laposte.net User-Agent: Thunderbird 1.5.0.9 (X11/20070103) MIME-Version: 1.0 To: Caml List Subject: Re: [Caml-list] CAMLreturn does not work for floats between 0 and 1 ? References: <45D5C3AD.2000606@laposte.net> <98085E4A-B42B-4570-90DC-842ABA89F5D6@epfl.ch> <45D5D9DC.8050704@laposte.net> <16855695-F439-47FB-80D1-171CD88833C2@epfl.ch> In-Reply-To: <16855695-F439-47FB-80D1-171CD88833C2@epfl.ch> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit From: Matthieu Dubuget X-j-chkmail-Score: MSGID : 45D603A7.000 on concorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at concorde with ID 45D603A7.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlreturn:01 matthieu:01 dubuget:01 matthieu:01 dubuget:01 bunzli:01 ocaml:01 camlparam:01 camlparam:01 camlreturn:01 ocaml:01 20,:98 misused:98 0.05:98 invoke:01 Daniel Bünzli a écrit : > > Le 16 févr. 07 à 17:20, Matthieu Dubuget a écrit : > >> Suppose that I have to construct one or more value(s) to pass them to >> OCaml land. I do have to use CAMLlocal macros for that, don't I. > > It depends. If you _allocate_ (e.g. ints are not allocated) a caml > value v1 then another caml v2 and then modify v1, you need to keep a > hand on v1 with CAMLparam because it may move when you allocate v2. If > you allocate only a single value then there is no need to do it > (unless some code you call may invoke the gc before you use v1). That means that I will have to review carefully my code... > >> Can use them without CAMLparam and CAMLreturn macros? > > No. But I never did the C -> ocaml -> C way so I don't really know how > to proceed. The first thing that comes to mind is to store the result > in a variable given to the function. Yes. That's the solution I was planning. It took me a long time to narrow the problem, because I have a lot of calls of this kind and was never bitten by this problem. But at first glance, i did not find one in my libraries with would have returned a small float value. The problem is not the solution, but the fact that I will have to review my code to check all this. > > > Maybe there's another way, I don't know. At the first place, except the fact that I misused the macros, I still do not understand why CAMLreturn(0.05) would return 0.? Thanks for your replies. Matt