caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Romain Bardou <romain.bardou@inria.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Auxiliary C function which manipulates the OCaml heap
Date: Tue, 12 Mar 2013 15:54:52 +0100	[thread overview]
Message-ID: <513F41BC.7070509@inria.fr> (raw)

Hello,

I have a C function "aux" which may either:
- raise an OCaml exception with caml_raise_with_arg;
- return void.

The argument of caml_raise_with_arg is allocated in "aux". So I should 
be careful and declare it to the GC. I do so using CAMLlocal.

However, this function does not use CAMLreturn, as it does not return an 
OCaml value but a C value (actually void). So the compiler emits a 
warning: "unused variable 'caml__frame'" if I use CAMLparam in aux.

Is it ok to call CAMLlocal in this way? The documentation says it cannot 
be called inside nested blocks. Is an auxiliary function considered a 
nested block?

Note that the caller of "aux", or (in another case) the caller of the 
caller of "aux", has called CAMLparam. If this was not the case, would 
it make a difference?

Similarly, if "aux" had some OCaml value arguments, should it call 
CAMLparam even though the caller of "aux" has declared them to the GC 
using CAMLparam or CAMLlocal?

Similarly, if "aux" did return an OCaml value, should it call CAMLreturn 
(and thus CAMLparam) to return the value, or should it use the normal 
"return"?

Thanks,

-- 
Romain Bardou

             reply	other threads:[~2013-03-12 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-12 14:54 Romain Bardou [this message]
2013-03-12 15:13 ` Jeremie Dimino

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=513F41BC.7070509@inria.fr \
    --to=romain.bardou@inria.fr \
    --cc=caml-list@inria.fr \
    /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).