Why does overridng the handle delete method and setting it to hidden cause a warning to be generated?

5 views (last 30 days)
Background; I have a reasonably complex set of objects, and a base of 6-7 people interested in them. I've read (anecdotally) that the primary way people explore API's is via tab completion.
I don't want generic matlab handle methods confusing people with what each object does, as opposed to the nature of it being an object. Therefore I want to hide certain methods, for example, the delete method.
classdef SomeClass < handle
methods(Hidden, Access = public)
function delete(varargin)
delete@handle(varargin{:});
end
end
end
Now, this appears to generate a warning;
Warning: The following error was caught while executing 'SomeClass' class destructor:
Method 'delete' is not defined for class 'SomeClass' or is removed from MATLAB's search path.
> In restoredefaultpath (line 52)
In something (line 2)
This method is definitely defined. Can anyone offer feedback on what's happening here, as it appears illogical to me?
  1 Comment
Adam
Adam on 21 Aug 2017
Edited: Adam on 21 Aug 2017
I don't get any warnings when I create and then delete an object of that class (in R2017a). Are you sure you cleared all objects of the class before making your changes? What is 'something' and more specifically what is it that is on line 2 that causes the error?

Sign in to comment.

Answers (1)

Simon Parten
Simon Parten on 21 Aug 2017
Adam is quite right that this object is part of a deeper chain.
I don't understand why, but I couldn't get a simply example to work. However, changing the code to include an output argument... i.e.
classdef SomeClass < handle
methods(Hidden, Access = public)
function obj = delete(varargin)
obj = delete@handle(varargin{:});
end
end
end
Apears to solve the problem...

Categories

Find more on Construct and Work with Object Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!