[Scilab-users] %mlistType_clear overloading of clear() for mlist custom types
Stéphane Mottelet
stephane.mottelet at utc.fr
Wed Jul 1 13:32:06 CEST 2020
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 at 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20200701/06e10f8e/attachment.htm>
More information about the users
mailing list