Classdef: Difference between revisions

Jump to navigation Jump to search
831 bytes added ,  22 April 2019
(removed fixed bug reports: #45351 (function handles),)
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page is a stub. We should begin documenting what classdef is implemented and what is not.
=== Features that are not implemented ===


=== Not Supported ===
* '''enumeration'''
 
Octave should be able to parse the enumeration section of a classdef definition but nothing is done with it.  Progress on this feature is tracked in bug report {{bug|44582}}.


* '''enumeration'''
* '''events and listeners'''


See {{bug|44582}} and help implementing it.
Octave should be able to parse the events section of a classdef definition but nothing is done with it.  Progress on this feature is tracked in bug report {{bug|56194}}.


* '''built-in class as superclass'''


* '''build-in class as superclass'''
Octave does not allow subclassing built-in classes.  In Matlab, classdef objects may subclass built-in integer, floating point, and logical types.  For example,
<source lang="octave">
<source lang="octave">
classdef nonsense < uint32
classdef nonsense < uint32
 
  ...
end
end
</source>
</source>


See {{bug|44035}}
does not work.


* '''[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].'''  
Progress on this feature is tracked in bug report {{bug|44035}}.
 
* '''concatenation of classdef objects'''
 
Octave does not support concatenation of classdef objects to create classdef array objects.


Example:
Example:
<source lang="octave">
<source lang="octave">
classdef MyClass < handle
classdef MyClass < handle
Line 33: Line 42:
</source>
</source>


Also see {{bug|44665}}
Progress on this feature is tracked in bug reports {{bug|44665}} and {{bug|53906}}.


* '''[http://www.mathworks.com/help/matlab/matlab_oop/mutable-and-immutable-properties.html Immutable property] set access.'''
* '''Saving and loading classdef objects'''
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.
Saving and loading classdef objects is not supported.


Progress on this feature is tracked in bug report {{bug|45833}}


* '''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.'''
=== Supported ===
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>
 
See {{bug|41723}}.
 
* '''debugging in classdef methods (and +package directory functions)'''


Breakpoints cannot currently be set in classdef methods from the gui, but only from the command line:
* Methods
<source lang="octave">
dbstop @aclass\amethod
</source>


See {{bug|45404}}
Classdef methods are supported but not all attributes are fully implemented.


* '''Saving/reading classdef objects to/from (.mat) file'''
{| class="wikitable"
|-
! style="text-align:left;"| Attribute
! Support
! Notes
|-
|Abstract
|Partial
|See bug report {{bug|51377}}
|-
|Access
|Yes
|
|-
|Hidden
|Yes
|
|-
|Sealed
|Yes
|
|-
|Static
|Yes
|
|}


=== Supported ===
* Properties


* methods
Classdef properties are supported but not all attributes are implemented.
** static
** private


* properties
{| class="wikitable"
** SetAccess (public/private/protected)
|-
! style="text-align:left;"| Attribute
! Support
! Notes
|-
|AbortSet
|No
|Property does not exist.
|-
|Abstract
|Yes
|
|-
|Access
|Partial
|
|-
|Constant
|Yes
|
|-
|Dependent
|Partial
|
|-
|GetAccess
|Partial
|
|-
|GetObservable
|No
|Property exists but is not used.  Requires events and listeners to be implemented in order to work properly.
|-
|Hidden
|Yes
|
|-
|NonCopyable
|No
|Property does not exist.
|-
|SetAccess
|Partial
|
|-
|SetObservable
|No
|Property exists but is not used.  Requires events and listeners to be implemented in order to work properly.
|-
|Transient
|No
|Property exists but is not used.
|}


=== Open Bug Reports ===
=== Open Bug Reports for Issues not Described Above ===


Issues with basic classdef functionality
Issues with basic classdef functionality
Line 103: Line 154:
* [https://savannah.gnu.org/bugs/?53874 53874] doc_cache_create doesnt handle classdef documentation
* [https://savannah.gnu.org/bugs/?53874 53874] doc_cache_create doesnt handle classdef documentation
* [https://savannah.gnu.org/bugs/?52096 52096] meta.class.fromName throws error when class name not found.
* [https://savannah.gnu.org/bugs/?52096 52096] meta.class.fromName throws error when class name not found.
* [https://savannah.gnu.org/bugs/?51377 51377] Parse error for abstract methods
* [https://savannah.gnu.org/bugs/?44665 44665] error in concatenation of classdef objects
* [https://savannah.gnu.org/bugs/?44582 44582] classdef: missing support for enumeration
* [https://savannah.gnu.org/bugs/?48693 48693] classdef subsref method is not called with correct nargout value
* [https://savannah.gnu.org/bugs/?48693 48693] classdef subsref method is not called with correct nargout value
* [https://savannah.gnu.org/bugs/?56006 56006] Object indexing: obj(1).property(end+1:n) - end is interpreted wrong
* [https://savannah.gnu.org/bugs/?55983 55983] 'x(ix) = []' deletion syntax does not work for objects
* [https://savannah.gnu.org/bugs/?55976 55976] cat, repmat, and reshape don't work for classdef objects
* [https://savannah.gnu.org/bugs/?55961 55961] properties function does not preserve order
* [https://savannah.gnu.org/bugs/?55768 55768] display of classdef object should not show private or protected properties
* [https://savannah.gnu.org/bugs/?55766 55766] properties function should not return Hidden properties
* [https://savannah.gnu.org/bugs/?55746 55746] interpreter fails to instantiate classdef with classdef properties


Classdef and +package directories
Classdef and +package directories
Line 114: Line 169:
Arrays of classdef objects
Arrays of classdef objects


* [https://savannah.gnu.org/bugs/?53906 53906] Cannot make an object array with square brackets
* [https://savannah.gnu.org/bugs/?47755 47755] Access to object arrays
* [https://savannah.gnu.org/bugs/?47755 47755] Access to object arrays
* [https://savannah.gnu.org/bugs/?47241 47241] classdef: assigning property of handle object in object array constructs new object
* [https://savannah.gnu.org/bugs/?47241 47241] classdef: assigning property of handle object in object array constructs new object


I/O issues
Debugger (fixes for these are in progress)
 
* [https://savannah.gnu.org/bugs/?45833 45833] support load/save of classdef objects
 
Debugger


* [https://savannah.gnu.org/bugs/?46451 46451] unable to set breakpoints within classdef classes
* [https://savannah.gnu.org/bugs/?46451 46451] unable to set breakpoints within classdef classes
Line 143: Line 193:
* [https://savannah.gnu.org/bugs/?55810 55810] sizeof() and whos() returns 0 bytes for classdef objects
* [https://savannah.gnu.org/bugs/?55810 55810] sizeof() and whos() returns 0 bytes for classdef objects
* [https://savannah.gnu.org/bugs/?45893 45893] classdef properties are not reloaded when file is updated
* [https://savannah.gnu.org/bugs/?45893 45893] classdef properties are not reloaded when file is updated
* [https://savannah.gnu.org/bugs/?44934 44934] classdef parser prints extra newline when failing to parse bad classdef file
* [https://savannah.gnu.org/bugs/?44643 44643] classdef handle object can go into an recursive loop with isequal(obj1,obj2) if both are self-referential
* [https://savannah.gnu.org/bugs/?44643 44643] classdef handle object can go into an recursive loop with isequal(obj1,obj2) if both are self-referential
* [https://savannah.gnu.org/bugs/?44035 44035] classdef is unable to to subclass double
* [https://savannah.gnu.org/bugs/?55755 55755] mxGetProperty does not work with properties marked as Dependent
* [https://savannah.gnu.org/bugs/?55767 55767] classdef property should not be the same as classdef name (at least for Matlab compatibility)


Documentation
Documentation

Navigation menu