caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Is Weak.get guaranteed to return Some until finalisation is executed?
@ 2003-11-14 22:07 Aleksey Nogin
  2003-11-18 12:21 ` Damien Doligez
  0 siblings, 1 reply; 2+ messages in thread
From: Aleksey Nogin @ 2003-11-14 22:07 UTC (permalink / raw)
  To: caml-list

Hello,

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? 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)?

-- 
Aleksey Nogin

Home Page: http://nogin.org/
E-Mail: nogin@cs.caltech.edu (office), aleksey@nogin.org (personal)
Office: Jorgensen 70, tel: (626) 395-2907

-------------------
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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Is Weak.get guaranteed to return Some until finalisation is executed?
  2003-11-14 22:07 [Caml-list] Is Weak.get guaranteed to return Some until finalisation is executed? Aleksey Nogin
@ 2003-11-18 12:21 ` Damien Doligez
  0 siblings, 0 replies; 2+ messages in thread
From: Damien Doligez @ 2003-11-18 12:21 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-11-18 12:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-14 22:07 [Caml-list] Is Weak.get guaranteed to return Some until finalisation is executed? Aleksey Nogin
2003-11-18 12:21 ` Damien Doligez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).