Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Basile STARYNKEVITCH <basile@starynkevitch.net>
To: guillaume.yziquel@citycable.ch
Cc: Luca de Alfaro <luca@dealfaro.org>, caml-list@inria.fr
Subject: Re: [Caml-list] Re: How to wrap around C++?
Date: Tue, 09 Feb 2010 07:53:19 +0100	[thread overview]
Message-ID: <4B71065F.6050601@starynkevitch.net> (raw)
In-Reply-To: <4B704D68.4000404@citycable.ch>

Guillaume Yziquel wrote:
> Essentially, the garbage collector will run potentially each time you 
> allocate an OCaml value. caml_copy_string? the GC may run.

The garbage collector may also run when calling (from C or C++ code) a callback, that is a function like caml_callback 
... (see section 18.7 of the manual), since this apply an Ocaml closure which of course will allocate Ocaml values.

In practical terms, you should consider that the Ocaml GC can be invoked by any C function from the Ocaml runtime (as 
seen by your C or C++ code) and that it moves pointers at every invocation.

So you better be safe and play carefully Ocaml rules.

Unless you really understand all the details of Ocaml runtime, I strongly recommend against playing tricks with Ocaml, 
for instance trying to avoid CAMLlocalX or CAMLparamX or CAMLreturn macros.

Regards.
-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***


  parent reply	other threads:[~2010-02-09  6:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08  2:13 Luca de Alfaro
2010-02-08  4:06 ` Michael Ekstrand
2010-02-08  4:17   ` Michael Ekstrand
2010-02-08 16:03   ` [Caml-list] " Luca de Alfaro
2010-02-08 16:33     ` Luca de Alfaro
2010-02-08 17:44       ` Guillaume Yziquel
2010-02-08 17:57         ` Luca de Alfaro
2010-02-09  6:53         ` Basile STARYNKEVITCH [this message]
2010-02-08 17:54     ` Guillaume Yziquel
2010-02-09  0:25     ` Michael Ekstrand
2010-02-08 12:38 ` [Caml-list] " Guillaume Yziquel

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=4B71065F.6050601@starynkevitch.net \
    --to=basile@starynkevitch.net \
    --cc=caml-list@inria.fr \
    --cc=guillaume.yziquel@citycable.ch \
    --cc=luca@dealfaro.org \
    /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