Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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.

Daniel