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
understanding weak
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-10-31 (08:37)
From: Daniel_Bünzli <daniel.buenzli@e...>
Subject: Re: [Caml-list] understanding weak

Le 31 oct. 08 ŕ 03:14, Martin Jambon a écrit :

> Warren Harris wrote:
>> I'd like to understand better how ocaml's weak pointers operate.  
>> First,
>> although it doesn't seem to be specified in the documentation, I  
>> assume
>> that weak pointers will *not* be reclaimed (e.g. from a weak hash  
>> table)
>> if the program retains some other reference to the object. I.e. the  
>> weak
>> pointer must be the last remaining pointer to the object for  
>> reclamation
>> to occur.
> Yes, otherwise the program would crash.

No since Weak.get returns an option type. As written the documentation  
sounds like the binding could disappear from the array even though the  
program still has references to the value. This could be done,  
wouldn't be usefull, but wouldn't crash the program.