From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=AWL,DNS_FROM_SECURITYSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 32072BB84 for ; Fri, 31 Oct 2008 20:13:06 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsAEANf1CknYDn+0/2dsb2JhbACBdsxzg1GBQw X-IronPort-AV: E=Sophos;i="4.33,523,1220220000"; d="scan'208";a="16729192" Received: from ns.n0bu.com (HELO main.n0bu.com) ([216.14.127.180]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 31 Oct 2008 20:13:05 +0100 Received: from hp.nogin.org (c-71-195-112-11.hsd1.ca.comcast.net [71.195.112.11]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by main.n0bu.com (Postfix) with ESMTPSA id 6E293F1A108C; Fri, 31 Oct 2008 12:13:01 -0700 (PDT) Message-ID: <490B58BA.6090307@metaprl.org> Date: Fri, 31 Oct 2008 12:12:58 -0700 From: Aleksey Nogin Reply-To: OCaml Mailing List Organization: MetaPRL/Mojave Research Group User-Agent: Thunderbird 2.0.0.17 (X11/20081001) MIME-Version: 1.0 To: Martin Jambon Cc: OCaml Mailing List Subject: Re: [Caml-list] understanding weak References: <490A6A19.9050704@ens-lyon.org> <9E14E68C-5480-46B8-9426-11EE40B6B139@erratique.ch> <490B1CDC.8080808@ens-lyon.org> In-Reply-To: <490B1CDC.8080808@ens-lyon.org> X-Enigmail-Version: 0.95.7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; gc'ed:01 gced:01 orphaned:01 wrote:01 caml-list:01 int:01 jambon:01 arbitrary:02 ambiguous:02 let:03 let:03 somewhat:05 fst:06 fst:06 weak:06 On 31.10.2008 07:57, Martin Jambon wrote: > let x = (1, 2);; > let wa = Weak.create 10;; > Weak.set wa 0 (Some x);; > ... > print_int (fst x);; > > (fst x) would certainly cause funny effects if x were GC'ed at an > arbitrary time after it has been added to the weak array. > > An object can be reclaimed by the GC only if there is no reference to > it. This remains true. Adding an object to a weak array just doesn't > count as a reference. > Martin, You are answering the wrong question - you are answering "could x be GCed too early?" - the answer is obviously "no". However, the initial question was "could (Some x) be removed from wa too early by GC - before x is orphaned?" The answer is "we'd hope not", but the documentation is somewhat ambiguous. Aleksey