[Contents] [TitleIndex] [WordIndex

1. SEP: add a `%foo_clear` overloading

2. Abstract

Some Scilab features are implemented through a mlist object and using the overloading mechanism to call a generic gateway on an operation. This is the case for the external_object (and JIMS), xml and hdf5 functionalities. To correctly call a destructor (to release resources, free mapping tables, etc...) a specific gateway is implemented and should be called to avoid memory leaks. This SEP propose to add an overloading %foo_clear called on foo mlist destruction to avoid the specific gateway thus let the mlist behave as other Scilab values.

3. Requirements

A %foo_clear function should be called on foo mlist destruction by the interpreter. If not defined, no error is produced and nothing is performed instead. This function will take an argument representing the deleted mlist value;

Atop of this deletion management, Scilab functionalities could be improved to handle this new behavior. For example, jremove (from external_object_java), xmlDelete (from xml) and h5close (from hdf5) could be called on deletion to avoid resource leaks and let the user clear the associated mlist.

The following bugs have been entered on Bugzilla to track similar or related problems/wishlist:

3.2. Mailing list threads

http://mailinglists.scilab.org/SEP-add-a-foo-delete-overloading-td4038898.html

3.3. Other software

4. Examples

4.1. Explicit call

   1 function %foo_clear(o)
   2         disp("resource deleted")
   3 endfunction
   4 
   5 value = mlist("foo");
   6 clear value

4.2. Implicit call

   1 function %foo_clear(o)
   2     disp("clear foo");
   3 endfunction
   4 
   5 function do_someting()
   6     value = mlist("foo");
   7 endfunction
   8 
   9 do_someting(); // %foo_clear will be call at the end of do_something

   1 function %foo_clear(o)
   2     disp("clear foo");
   3 endfunction
   4 
   5 function value = do_someting_and_return()
   6     value = mlist("foo");
   7 endfunction
   8 
   9 x = do_someting_and_return();
  10 x = 1; //call %foo_clear overload before replace


CategorySep


2022-09-08 09:27