English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Weak module
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-07-24 (04:32)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] Weak module
From: "Jonathan Roewen" <jonathan.roewen@gmail.com>
> For the weak module, if some value is pointing to another value which 
> is in a weak array, can that value be erased by the Gc still?
> e.g. type my_t = (int32, int32_elt, c_layout) Array1.t (* bigarray *)
> and I had a weak array of my_t, and was holding on to an int32 inside 
> the bigarray...

You cannot hold on to anything inside a bigarray: this is just an
array of bytes where you read and write data. A new int32 block is
allocated every time you extract a value from the bigarray.
Note that the same thing is true for a "float array": it is not an
array of pointers to floats, but a flat array of doubles.
In both cases, a pointer to the value you wrote in the array may be
disposed of afterwards, if nobody else keeps it.

Jacques Garrigue