Editing Classdef
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
This page is a stub. We should begin documenting what classdef is implemented and what is not. | |||
==== | ==== not supported ==== | ||
* enumeration | |||
* build-in class as superclass | |||
** <source lang="octave" enclose="none">classdef nonsense < uint32</source> | |||
= | * [http://www.mathworks.com/help/matlab/matlab_oop/redefining-concatenation-for-your-class.html concatenating objects] into [http://www.mathworks.com/help/matlab/matlab_oop/initialize-object-arrays.html array of objects]. Example: | ||
<source lang="octave"> | |||
classdef MyClass < handle | |||
end | |||
c = MyClass(); | |||
cc = [c, c]; % won't work | |||
</source> | |||
For now you can use a cell-array of objects instead: | |||
<source lang="octave"> | |||
cc = {c, c}; % ok | |||
</source> | |||
=== | * [http://www.mathworks.com/help/matlab/matlab_oop/mutable-and-immutable-properties.html Immutable property] set access. Example: | ||
<source lang="octave"> | |||
classdef MyClass < handle | |||
properties (SetAccess = immutable) | |||
x | |||
end | |||
methods | |||
function obj = MyClass() | |||
x = rand(); | |||
end | |||
end | |||
end | |||
</source> | |||
Use "private" properties as workaround. | |||
* { | * Function handles to package methods and static class methods. | ||
For example if we have <code>+mypackage/myfunc.m</code>, creating a function handle as <code>fh = @mypackage.myfunc</code> won't work. | |||
As a workaround, we can create an indirection using an anonymous function <code>fh = @(varargin) mypackage.myfunc(varargin{:})</code>. | |||
Similarly for static class methods where <code>fh = @MyClass.myfunc</code> isn't yet supported. | |||
* Defining [http://www.mathworks.com/help/matlab/matlab_oop/specifying-methods-and-functions.html#br2la89 local functions] in the same classdef-file is not working. For example, the following code gives a syntax/parse error: | |||
<source lang="octave"> | |||
classdef MyClass | |||
methods | |||
function obj = MyClass() | |||
myfunc() | |||
end | |||
end | |||
end | |||
function myfunc() | |||
disp('myfunc') | |||
end | |||
</source> | |||
* debugging in classdef methods (and +package directory functions) | |||
Breakpoints cannot currently be set in classdef methods (or at least they are ignored). They also can't be set in functions in +package directories (which is a related issue). | |||
==== | ==== supported ==== | ||
* | * methods | ||
* | ** static | ||
** private | |||
* | |||
* | |||
* | |||
==== Classdef | ==== Classdef examples in the wild ==== | ||
* | * http://hg.savannah.gnu.org/hgweb/octave/file/tip/scripts/general/inputParser.m | ||
* https://github.com/markuman/go-redis | |||
* https://github.com/PetrKryslUCSD/FinEALE | |||
* | |||
* | |||