[Scilab-users] %mlistType_clear overloading of clear() for mlist custom types

Samuel Gougeon sgougeon at free.fr
Wed Jul 1 13:13:53 CEST 2020


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

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


More information about the users mailing list