[Scilab-users] Counter of pointers to an XML object, and clear destructor

Samuel Gougeon sgougeon at free.fr
Mon Aug 6 18:12:27 CEST 2018


Hello Antoine,

Thanks for your answer. I am afraid that, from a user point of view -- 
that's mine--, it is hard to understand in pratical the way it works, 
and why it works like this:

Le 30/07/2018 à 00:55, Antoine ELIAS a écrit :
> Hello Samuel,
>
> In XMLObject there is two levels of reference,
>  - one on MList (managed by reference counter)
>  - one on internal XMLObject (internally manager like handle, an 
> integer that link to a C++ object)
>
> xmlDelete destroy internal XMLObject
> clear destroy (unreference and destroy if ref <= 1 ) MList object.

How is it possible to illustrate all this with Scilab instructions and 
tests?
In what you describe, i don't see any difference between Scilab 5 and 
Scilab 6,
contrarily to Calixte's announcement, noticeably about the way clear() 
works.

>
> So in your case, after a xmlDelete, the internal XMLObject was 
> destroyed but not the MList.
> And after a clear doc, the MList was destroyed but the internal 
> XMLObject not.

Yes, i understand all that.

> Current XMLObject is based on simple MList with the id of the doc ( 
> store as double ).
> If we want to correctly destroy the internal XMLObject with the clear 
> command.
> We must change the implementation to use types::UserType instead of 
> types::Double and uses destructor of UserType to free XMLObject.

So, is this the new possible feature of Scilab 6 vs Scilab 5?
In this way, i am not sure that this would be the most interesting 
evolution.
Even if an open document has no local handle, it is still possible to 
retrieve
an access to open ones, and from everywhere,  with xmlGetOpenDocs().
That's nice.

> > Deleting an object should clear all its pointers. For instance, with 
> the XML example
> > hereabove, deleting the document should clear doc and doc2.
> I am not agree with that, I cannot delete an user variable indirectly. 
> ( xmlDelete(doc) that will delete doc )
> Only clear command can do that. For me it will be a bad practice.

Why?! This is the key point. It holds in the same way for graphic handles.
I would like very much to read and understand rationales about this point.
 From a user point of view, i don't see a single reason or interest in
keeping "invalid handles" or "invalid XML documents", that's to say,
clearly, keeping some pending pointers! These are dead and completely 
useless
objects, since there is no way to recover the deleted target.
So, what's the interest in using is_handle_valid(h) instead of simply 
isdef("h")??
What's the interest of using xmlIsValidObject(doc) instead of isdef("doc")?
With such a current implementation, if we have created many alias of an 
handle,
then there are as many obsolete aliases that are pending pointers.

If you have in mind a single situation for which this implementation has
an interest (compared to an automatical clearing of invalid handles)
it would be great to share it.

Usually, leaving pending pointers is the bad practice, not removing them.
Isn't it?

Best regards
Samuel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180806/c8f67244/attachment.htm>


More information about the users mailing list