caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matthieu Dubuget <matthieu.dubuget@gmail.com>
To: Caml List <caml-list@inria.fr>
Subject: Re: [Caml-list] CAMLreturn does not work for floats between 0 and 1 ?
Date: Fri, 16 Feb 2007 20:19:00 +0100	[thread overview]
Message-ID: <45D603A4.7080500@laposte.net> (raw)
In-Reply-To: <16855695-F439-47FB-80D1-171CD88833C2@epfl.ch>

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 \x13v1 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


  reply	other threads:[~2007-02-16 19:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-16 14:46 Matthieu Dubuget
2007-02-16 15:09 ` [Caml-list] " Daniel Bünzli
2007-02-16 16:20   ` Matthieu Dubuget
2007-02-16 17:02     ` Mathias Kende
2007-02-16 17:07     ` Daniel Bünzli
2007-02-16 19:19       ` Matthieu Dubuget [this message]
2007-02-16 22:28         ` Daniel Bünzli
2007-02-17  0:30 ` Jacques Garrigue

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45D603A4.7080500@laposte.net \
    --to=matthieu.dubuget@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=matthieu.dubuget@laposte.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).