Can I use Matlab's default implementation of empty with matlab.mixin.indexing.RedefinesParen?
1 view (last 30 days)
I'm trying to use the new method of overloading indexing with the matlab.mixin.indexing.RedefinesParen class, new in 2021b. However, I like and am fine with Matlab's default implementation of empty, which becomes Abstract and requires definition in classes that inherit from RedefinesParen. In fact, I'm making a general top-level class and I'm trying to make things easy on developers, so I like that the default implementation of empty for classes doesn't have to worry about property validation, which is sometimes defined in the constructor rather than with the property definition.
Overloading empty and choosing an "empty" property that will pass through error-checking in the constructor is an extra layer of worry that I am hoping developers will not have to worry about when inheriting from this class. Is there any way to use the default empty that Matlab implements behind-the-scenes for classes that inherit from RedefinesParen or am I out-of-luck on this front?
James Lebak on 27 Apr 2022
You do have to provide an 'empty' for your class that inherits from RedefinesParen. Such classes are scalars masquerading as arrays, and MATLAB unfortunately can't guarantee that its default empty will be functionally correct in all cases for such classes.
If you provide your own implementation of 'empty', then classes that inherit from your class should not need to do anything extra.