From: "Harry Chomsky" <harry@chomsky.net>
To: "Daniel de Rauglaudre" <daniel.de_rauglaudre@inria.fr>
Cc: "Caml list" <caml-list@inria.fr>
Subject: Re: [Caml-list] Win32 API
Date: Thu, 31 May 2001 15:59:55 -0700 [thread overview]
Message-ID: <00ff01c0ea25$68d716f0$22f65140@w2kpro> (raw)
In-Reply-To: <20010601001301.A11836@verdot.inria.fr>
> When you
> call an OCaml alloc function, all your variables of type "value" may
> point to wrong places.
OK, I think I'm understanding this better now. So if a C function does all
of its work using simple macros like Val_int then it's ok, but if it does
anything that might cause the OCaml runtime to allocate memory, then it has
to use the CAMLparam and CAMLreturn macros as described in the
documentation. Is that right?
Now I understand also why the naming conventions differ so radically between
e.g. Val_int and copy_int32. Clearly the former just manipulates bits while
the latter allocates memory. I had thought this was an insignificant
distinction, so when I wrote functions like copy_int32 I named them
Val_handle etc. I thought this made the code read more easily. But I see
now why the distinction matters.
I will go through my existing code to make it use the CAML* macros where
necessary and rename the Val_* functions to copy_*. I'll write to the list
again when I have posted these modifications.
(To the writers of the [mostly superb] documentation: The rules listed in
"Living in harmony with the garbage collector" are very clear, but most of
the sample C code in the other sections of the chapter don't follow the
rules. Perhaps the documentation could explain not just how to follow the
rules but also *when* to follow them, and why they are ignored in those
samples. Thanks!)
-------------------
To unsubscribe, mail caml-list-request@inria.fr. Archives: http://caml.inria.fr
next prev parent reply other threads:[~2001-05-31 22:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-05-31 20:34 Harry Chomsky
2001-05-31 22:13 ` Daniel de Rauglaudre
2001-05-31 22:59 ` Harry Chomsky [this message]
2001-06-01 11:48 ` Daniel de Rauglaudre
2001-06-04 4:01 ` Harry Chomsky
2001-06-04 4:49 ` Daniel de Rauglaudre
2001-06-04 8:53 ` Stefan Monnier
2001-06-02 14:56 ` Dmitry Bely
2001-12-31 20:52 Harry Chomsky
2002-01-01 18:22 ` Warp
2002-01-02 4:56 ` Harry Chomsky
2002-01-02 20:27 ` Warp
2002-01-12 21:37 ` Harry Chomsky
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='00ff01c0ea25$68d716f0$22f65140@w2kpro' \
--to=harry@chomsky.net \
--cc=caml-list@inria.fr \
--cc=daniel.de_rauglaudre@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