Re: [Scilab-users] %mlistType_clear overloading of clear() for mlist custom types
Hello all, Indeed this introduction was made to fulfill the needs for external objects to be clear as any other Scilab variables. I made some early prototypes for hdf5 and xml but failed to push them further. IMHO this is feasible but there are some specific needs for each overloading (clearing the H5objects table with -1 to make the slot available for HDF5; dereferencing the element on the general doc instance for XML). Thanks, Clément DAVID > -Original Message- > From: users On Behalf Of Stéphane Mottelet > Sent: Wednesday, July 1, 2020 6:59 PM > To: users@lists.scilab.org > Subject: Re: [Scilab-users] %mlistType_clear overloading of clear() for mlist > custom types > > > > > Le 01/07/2020 à 18:52, Samuel Gougeon a écrit : > > > Le 01/07/2020 à 13:47, Stéphane Mottelet a écrit : > > > Right, sorry for my previous message. > > > But, at the user level there are very few use cases: the clear > overload is only useful if some mlist fields contain some pointers to > allocated > data. For example sparse LU factors or Java objects. > > > > > The auto-clearing of the Java side of Java objects is already > implemented (and it's documented). > > > I am not sure it worked perfectly before. Clement's patch is essentially > dealing > with this case, see e.g.: > > https://codereview.scilab.org/#/c/20679/14/scilab/modules/external_objects/s > ci_gateway/cpp/sci_percent_EObj_clear.cpp > > https://codereview.scilab.org/#/c/20679/14/scilab/modules/external_objects/s > rc/cpp/clear.cpp > > > S. > > > > > > > I am wondering if a similar native auto-clearing could be implemented > for xml and hdf5 objects. > I guess that using clear before h5close() or xmlDelete() could make > memory leaking. > > Samuel > > > > > ___ > users mailing list > users@lists.scilab.org <mailto:users@lists.scilab.org> > https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLm > Zy/lists.scilab.org/mailman/listinfo/users > > -- > Stéphane Mottelet > Ingénieur de recherche > EA 4297 Transformations Intégrées de la Matière Renouvelable Département > Génie des Procédés Industriels Sorbonne Universités - Université de > Technologie > de Compiègne CS 60319, 60203 Compiègne cedex Tel : +33(0)344234688 > http://www.utc.fr/~mottelet ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] %mlistType_clear overloading of clear() for mlist custom types
Le 01/07/2020 à 18:52, Samuel Gougeon a écrit : Le 01/07/2020 à 13:47, Stéphane Mottelet a écrit : Right, sorry for my previous message. But, at the user level there are very few use cases: the clear overload is only useful if some mlist fields contain some pointers to allocated data. For example sparse LU factors or Java objects. The auto-clearing of the Java side of Java objects is already implemented (and it's documented). I am not sure it worked perfectly before. Clement's patch is essentially dealing with this case, see e.g.: https://codereview.scilab.org/#/c/20679/14/scilab/modules/external_objects/sci_gateway/cpp/sci_percent_EObj_clear.cpp https://codereview.scilab.org/#/c/20679/14/scilab/modules/external_objects/src/cpp/clear.cpp S. I am wondering if a similar native auto-clearing could be implemented for xml and hdf5 objects. I guess that usingclear before h5close() or xmlDelete() could make memory leaking. Samuel ___ users mailing list users@lists.scilab.org https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users -- Stéphane Mottelet Ingénieur de recherche EA 4297 Transformations Intégrées de la Matière Renouvelable Département Génie des Procédés Industriels Sorbonne Universités - Université de Technologie de Compiègne CS 60319, 60203 Compiègne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] %mlistType_clear overloading of clear() for mlist custom types
Le 01/07/2020 à 18:46, Samuel Gougeon a écrit : Le 01/07/2020 à 13:29, Lamy Alain a écrit : Hello Samuel, Comparing with the example in the « clear » page, the “%test_clear” function must have one argument : --> m = mlist("test"); --> function %test_clear(x) > disp("mlist test cleared") > endfunction --> clear m; "mlist test cleared" Thank you, Alain. I did not pay attention to the example. I will fix the page to indicate that at least one argin is required, I think that exactly one argin is required. provided that this requirement is intentional. Samuel ___ users mailing list users@lists.scilab.org https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users -- Stéphane Mottelet Ingénieur de recherche EA 4297 Transformations Intégrées de la Matière Renouvelable Département Génie des Procédés Industriels Sorbonne Universités - Université de Technologie de Compiègne CS 60319, 60203 Compiègne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] %mlistType_clear overloading of clear() for mlist custom types
Le 01/07/2020 à 13:47, Stéphane Mottelet a écrit : Right, sorry for my previous message. But, at the user level there are very few use cases: the clear overload is only useful if some mlist fields contain some pointers to allocated data. For example sparse LU factors or Java objects. The auto-clearing of the Java side of Java objects is already implemented (and it's documented). I am wondering if a similar native auto-clearing could be implemented for xml and hdf5 objects. I guess that usingclear before h5close() or xmlDelete() could make memory leaking. Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] %mlistType_clear overloading of clear() for mlist custom types
Le 01/07/2020 à 13:29, Lamy Alain a écrit : Hello Samuel, Comparing with the example in the « clear » page, the “%test_clear” function must have one argument : --> m = mlist("test"); --> function %test_clear(x) > disp("mlist test cleared") > endfunction --> clear m; "mlist test cleared" Thank you, Alain. I did not pay attention to the example. I will fix the page to indicate that at least one argin is required, provided that this requirement is intentional. Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] %mlistType_clear overloading of clear() for mlist custom types
Right, sorry for my previous message. But, at the user level there are very few use cases: the clear overload is only useful if some mlist fields contain some pointers to allocated data. For example sparse LU factors or Java objects. S. Le 01/07/2020 à 13:29, Lamy Alain a écrit : Hello Samuel, Comparing with the example in the « clear » page, the “%test_clear” function must have one argument : --> m = mlist("test"); --> function %test_clear(x) > disp("mlist test cleared") > endfunction --> clear m; "mlist test cleared" Alain ___ users mailing list users@lists.scilab.org https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users -- Stéphane Mottelet Ingénieur de recherche EA 4297 Transformations Intégrées de la Matière Renouvelable Département Génie des Procédés Industriels Sorbonne Universités - Université de Technologie de Compiègne CS 60319, 60203 Compiègne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] %mlistType_clear overloading of clear() for mlist custom types
Hello Samuel, Comparing with the example in the « clear » page, the “%test_clear” function must have one argument : --> m = mlist("test"); --> function %test_clear(x) > disp("mlist test cleared") > endfunction --> clear m; "mlist test cleared" Alain ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
Re: [Scilab-users] %mlistType_clear overloading of clear() for mlist custom types
Hi, https://codereview.scilab.org/#/c/20679/ says: add a %foo_clear overloading on mlist This overload will be called at the end of the scope when a variable will not be accessible anymore for clearing allocated data. So it does not say that %foo_clear is called when using "clear". The following example seems more relevant: function %test_clear(t) disp cleared end function foo() m=mlist("test") end --> foo() "cleared" S. Le 01/07/2020 à 13:13, Samuel Gougeon a écrit : Hello, Scilab 6.1.0 brings a feature about clearing mlists, that can now be overloaded. However, it's a special overloading feature, that does not replace the role of clear(), but that comes in addition to it, as documented in the clear page: https://help.scilab.org/docs/6.1.0/en_US/clear.html "Note: |clear()|can be overloaded for any|mlist("foo")|type, by defining a|%foo_clear()|macro. It will be called either when|clear|is explicitly applied to any mlist of this type, or implicitly when any mlist of this type is deleted when leaving the environment where it has been defined." Now, when i try to use this feature, i do not get what i understand we should expect. Example: --> m = mlist("test"); --> typeof(m) ans = "test" --> function %test_clear() > disp("mlist test cleared") > endfunction --> clear m --> nothing is printed. We would expect "mlist test cleared", wouldn't we? What am i doing wrong? Regards Samuel ___ users mailing list users@lists.scilab.org https://antispam.utc.fr/proxy/1/c3RlcGhhbmUubW90dGVsZXRAdXRjLmZy/lists.scilab.org/mailman/listinfo/users -- Stéphane Mottelet Ingénieur de recherche EA 4297 Transformations Intégrées de la Matière Renouvelable Département Génie des Procédés Industriels Sorbonne Universités - Université de Technologie de Compiègne CS 60319, 60203 Compiègne cedex Tel : +33(0)344234688 http://www.utc.fr/~mottelet ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users
[Scilab-users] %mlistType_clear overloading of clear() for mlist custom types
Hello, Scilab 6.1.0 brings a feature about clearing mlists, that can now be overloaded. However, it's a special overloading feature, that does not replace the role of clear(), but that comes in addition to it, as documented in the clear page: https://help.scilab.org/docs/6.1.0/en_US/clear.html "Note: |clear()|can be overloaded for any|mlist("foo")|type, by defining a|%foo_clear()|macro. It will be called either when|clear|is explicitly applied to any mlist of this type, or implicitly when any mlist of this type is deleted when leaving the environment where it has been defined." Now, when i try to use this feature, i do not get what i understand we should expect. Example: --> m = mlist("test"); --> typeof(m) ans = "test" --> function %test_clear() > disp("mlist test cleared") > endfunction --> clear m --> nothing is printed. We would expect "mlist test cleared", wouldn't we? What am i doing wrong? Regards Samuel ___ users mailing list users@lists.scilab.org http://lists.scilab.org/mailman/listinfo/users