From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id NAA23677; Tue, 18 Nov 2003 13:20:53 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id NAA22921 for ; Tue, 18 Nov 2003 13:20:52 +0100 (MET) Received: from inria.fr (macaque.inria.fr [128.93.8.158]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id hAICKp104212 for ; Tue, 18 Nov 2003 13:20:52 +0100 (MET) Date: Tue, 18 Nov 2003 13:21:24 +0100 Subject: Re: [Caml-list] Is Weak.get guaranteed to return Some until finalisation is executed? Content-Type: text/plain; charset=US-ASCII; format=flowed Mime-Version: 1.0 (Apple Message framework v552) From: Damien Doligez To: caml-list@inria.fr Content-Transfer-Encoding: 7bit In-Reply-To: <3FB55226.9080707@cs.caltech.edu> Message-Id: X-Mailer: Apple Mail (2.552) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 damien:01 damien:01 pointers:01 liveness:01 pointers:01 doligez:01 doligez:01 imply:02 finalisation:02 finalisation:02 module:03 pointer:03 wrote:03 data:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Friday, November 14, 2003, at 11:07 PM, Aleksey Nogin wrote: > Currently the documentation for the Weak module seems to imply that > the Weak.get can return None whenever it feels like it. Is there any > guarantees as to when things are required to stay in the weak array? It is not documented, mostly because the documentation doesn't introduce the notions needed to talk about sharing, pointers, and liveness of data. It would be nice to do it, in order to give some precise specification of (==), weak pointers, and finalisation. But it is a large amount of work, as the corresponding theoretical work doesn't exist (as far as I know), and we should carefully avoid over-specifying. > In particular, if I call GC.finalise on a heap-allocated value and > then stick a value into a weak array, can I be sure that Weak.get will > return Some until after the finalisation function is executed (and > finishes its execution)? Definitely not. Weak pointers are erased first, and finalisation functions are called afterward. When the finalisation function is called, it really has the only existing pointer to the value. -- Damien ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners