<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/11/6e7b16172669003eddadf343f60fb496"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-11-12T12:48:48"
  subject="[Caml-list] Re: Constants immediatelly disappear from the Weak array. (PR#1925)"
  prev="2003/11/087666a124ab88cc69b9d0ba807a129d"
  next="2003/11/a493c676415d2097c4bf8c63da328c5c"
  next-in-thread="2003/11/34ce59d3f1b53cbaafa5e4edaea674ad"
  prev-thread="2003/11/087666a124ab88cc69b9d0ba807a129d"
  next-thread="2003/11/e8fd0dfd31a596714c76d480bdfae207"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Re: Constants immediatelly disappear from the Weak array. (PR#1925)">
<msg 
  url="2003/11/6e7b16172669003eddadf343f60fb496"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-11-12T12:48:48"
  subject="[Caml-list] Re: Constants immediatelly disappear from the Weak array. (PR#1925)">
<msg 
  url="2003/11/34ce59d3f1b53cbaafa5e4edaea674ad"
  from="Aleksey Nogin &lt;nogin@c...&gt;"
  author="Aleksey Nogin"
  date="2003-11-12T23:22:08"
  subject="Re: [Caml-list] Re: Constants immediatelly disappear from the Weak array. (PR#1925)">
</msg>
</msg>
</thread>

<contents>
On Wednesday, November 12, 2003, at 10:13 AM, Aleksey Nogin wrote:

&gt; When trying to switch from 3.06 to 3.07+2 I've noticed the following 
&gt; 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
]

&gt; Basically, in 3.07+2, the empty list disappears from the weak array as 
&gt; soon as it is added into it. Is this a bug or a feature?

Feature.


&gt; The old behavior is useful because it allows to assume that while a 
&gt; value is referenced somewhere, Weak.get will always return Some. This 
&gt; allowed using Weak.get as an indicator of whether it was OK to discard 
&gt; some "helper" data (which should be only discarded after the primary 
&gt; 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

</contents>

</message>

