<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hello,<br>
    <br>
    I am doing some tests about the save() function, in order to
    document its behavior when saving pointers to some objects.<br>
    <br>
    There is the case of XML objects:<br>
    Contrarily to graphic handles, that are pointers whose reloading
    restores the pointed graphics, saving XML pointers is possible, but
    then their reloading does NOT restore the XML document.<br>
    Then, when digging in Bugzilla in order to search for features about
    this and the clear() function applied to XML pointers, i've found
    back the following <a
      href="http://bugzilla.scilab.org/show_bug.cgi?id=13398#c2">comment
      from Calixte</a>, referring to an expected change of Scilab 6 with
    respect to Scilab 5:<br>
    <br>
    <i>With Scilab 6, things will be easier since each data will have a
      reference counter [of pointers to it] which will allow to call a
      kind of destructor when the reference count will be zero.</i><i><br>
    </i><br>
    In practical, this new feature looks still not to be implemented.
    Here is an illustration:<br>
    <br>
    <font size="-1"><tt>// Let's create an XML document and a pointer
        "doc" to it:</tt><tt><br>
      </tt><tt>--> doc = xmlReadStr("<root><a att=""foo""
        rib=""bar""><b>Hello</b></a></root>")</tt><tt><br>
      </tt><tt> doc  = </tt><tt><br>
      </tt><tt>XML Document</tt><tt><br>
      </tt><tt>url: Undefined</tt><tt><br>
      </tt><tt>root: XML Element</tt><tt><br>
      </tt><tt><br>
        // Now, let's make a copy of the pointer:</tt><tt><br>
      </tt><tt>-->doc2=doc</tt><tt><br>
      </tt><tt> doc2  =</tt><tt> </tt><tt><br>
      </tt><tt>XML Document</tt><tt><br>
      </tt><tt>url: Undefined</tt><tt><br>
      </tt><tt>root: XML Element</tt><tt><br>
      </tt><tt><br>
      </tt><tt>--> doc2==doc</tt><tt><br>
      </tt><tt> ans  =</tt><tt><br>
      </tt><tt>  T T    <<< this double True is strange, but
        it's not the matter here<br>
        <br>
        // Then let's clear both pointers: If a counter actually exists,<br>
        // it shall be set to 0 afterwards.<br>
        // And if the automatic destructor is implemented, then this
        should<br>
        // automatically delete the XML document. What's the reality?:<br>
        --> clear doc doc2   // OK<br>
        -->  xmlGetOpenDocs()<br>
         ans  =<br>
               ans(1)<br>
        XML Document<br>
        url: Undefined<br>
        root: XML Element<br>
        <br>
      </tt></font>The document still exists. So, the automatic
    destructor is not yet implemented,<br>
    at least for XML objects.<br>
    <br>
    Is it a pity? To me, the reverse approach would be more relevant:<br>
    Deleting an object should clear all its pointers. For instance, with
    the XML example<br>
    hereabove, deleting the document should clear doc and doc2.<br>
    It's unfortunately not the case:<br>
    <font size="-1"><tt>--> xmlDelete(xmlGetOpenDocs()(:))  //
        cleaning the area</tt><tt><br>
      </tt><tt>--> doc = xmlReadStr("<root><a att=""foo""
        rib=""bar""><b>Hello</b></a></root>");</tt><tt><br>
      </tt><tt>--> doc2 = doc;</tt><tt><br>
      </tt><tt>--> xmlDelete(doc)</tt><tt><br>
      </tt><tt>--> isdef(["doc" "doc2"],"l")</tt><tt><br>
      </tt><tt> ans  =</tt><tt><br>
      </tt><tt>  T T</tt><tt><br>
        --> doc<br>
         doc  = <br>
        --> <br>
        <br>
      </tt></font>This is the same issue with graphic handles when the
    figure they point to has been closed:<br>
    We then get some still existing <i>but invalid</i> handles, instead
    of properly clearing them.<br>
    <br>
    Regards<br>
    Samuel<br>
    <br>
    <br>
  </body>
</html>