[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Guillaume Yziquel <guillaume.yziquel@c...> |
| Subject: | Re: [Caml-list] problem creating .cma library |
Basile STARYNKEVITCH a écrit :
>>
>> Why do these functions not follow the usual CAMLparam/CAMLreturn macro
>> stuff?
>
> Because they are written by the Ocaml guys (Damien knows really well the
> Ocaml garbage collector; he wrote it). And also, because these
> particular functions do not do any allocation of Ocaml values (either
> directly or indirectly).
So, no allocation of OCaml values (or in place modification, either, I
guess) implies no need for CAMLparam/CAMLreturn stuff?
> My advice for people coding C code for ocaml is the following:
>
> 1. *always* use the CAMLparam/CAMLreturn/... macros.
>
> 2. if you dare not using them for some very few functions (because they
> don't allocate, ...) add a big fat comment with a warning inside.
>
> Regards
I want to understand them so that I can abstract away in some other file
/ .so, some rather usual constructs involving OCaml structures. I think
it is smarter to take some time doing this, with detailed comments all
over, than repeating the same mistakes over and over (or worse:
wondering if you made mistakes) when doing C bindings.
All the best,
--
Guillaume Yziquel
http://yziquel.homelinux.org/