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 NAA19404; Wed, 12 Nov 2003 13:48:48 +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 NAA19452 for ; Wed, 12 Nov 2003 13:48:47 +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 hACCmk125530; Wed, 12 Nov 2003 13:48:46 +0100 (MET) Date: Wed, 12 Nov 2003 13:49:05 +0100 Subject: [Caml-list] Re: Constants immediatelly disappear from the Weak array. (PR#1925) 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, caml-bugs@pauillac.inria.fr Content-Transfer-Encoding: 7bit In-Reply-To: <200311120908.KAA10511@pauillac.inria.fr> Message-Id: <9969407E-150E-11D8-AD29-00039310CAE8@inria.fr> X-Mailer: Apple Mail (2.552) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; constants:01 damien:01 damien:01 3.06:01 3.07:01 3.06,:01 3.07:01 disappears:01 disappears:01 bug:01 helper:01 3.06,:01 helper:01 pointers:01 doligez:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wednesday, November 12, 2003, at 10:13 AM, Aleksey Nogin wrote: > When trying to switch from 3.06 to 3.07+2 I've noticed the following > difference in how the Weak module works: [ In 3.06, an empty list [] does not disappear from a weak array; in 3.07+2 it disappears immediately ] > Basically, in 3.07+2, the empty list disappears from the weak array as > soon as it is added into it. Is this a bug or a feature? Feature. > The old behavior is useful because it allows to assume that while a > value is referenced somewhere, Weak.get will always return Some. This > allowed using Weak.get as an indicator of whether it was OK to discard > some "helper" data (which should be only discarded after the primary > data is no longer in use). Yes, but. In 3.06, [] will never be removed from the weak array, and you will keep your helper data forever. The source your the problem is that [] is not allocated in the heap. It is represented by an integer value. Hence, there is no sharing between various occurrences of [] in your data and the notion of a weak pointer to [] does not make sense. If you really want to make sure that you are manipulating pointers, you should use a record or a list ref. -- 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