Version française
Home     About     Download     Resources     Contact us    
Browse thread
C interface style question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Thomas Fischbacher <Thomas.Fischbacher@P...>
Subject: Re: [Caml-list] C interface style question

On Thu, 19 Jan 2006, Jacques Garrigue wrote:

> Registration is required to have the GC properly update the values.
> The GC may be called by any allocation.

Just by allocations in the local C code? Is this (and will this always 
be) a guaranteed property? How about future extensions and multithreading?

> So it is only safe not to register a parameter (or a variable) in any
> of the following 4 cases.
> 1) you know that it can only hold a non-pointer value (int, bool, ...)
>    (i.e. the GC has nothing to update)
> 2) there are no allocations in your function
> 3) the parameter is not accessed after the first allocation
> 4) for a new variable whose contents is returned, there is no
>    allocation between the setting of the variable and return.
> 
> (1) and (2) are relatively easy to see, but (3) and (4) are a bit
> trickier (particularly with side-effecting expressions), so
> it is not a bad idea to register more parameters than strictly
> necessary.

Can I take this as an official position of the OCaml team on the behaviour 
of the C interface?

-- 
regards,               tf@cip.physik.uni-muenchen.de              (o_
 Thomas Fischbacher -  http://www.cip.physik.uni-muenchen.de/~tf  //\
(lambda (n) ((lambda (p q r) (p p q r)) (lambda (g x y)           V_/_
(if (= x 0) y (g g (- x 1) (* x y)))) n 1))                  (Debian GNU)