User`s guide
Compiling Private and Method Functions
5-5
Compiling Private and Method Functions
Private functions are functions that reside in subdirectories with the special
name
private, and are visible only to functions in the parent directory. Since
private functions are invisible outside of the parent directory, they can use the
same names as functions in other directories. Because MATLAB looks for
private functions before standard M-file functions, it will find a private
function before a nonprivate one.
Method functions are implementations specific to a particular MATLAB type
or user-defined object. Method functions are only invoked when the argument
list contains an object of the correct class.
In order to compile a method function, you must specify the name of the method
along with the classname so that the Compiler can differentiate the method
function from a nonmethod (normal) function.
Note Although MATLAB Compiler 3.0 can currently compile method
functions, it does not support overloading of methods as implemented in
MATLAB. This feature is provided in anticipation of support of overloaded
methods being added.
Method directories can contain private directories. Private functions are found
only when executing a method from the parent method directory. Taking all of
this into account, the Compiler command line needs to be able to differentiate
between these various functions that have the same name. A file called
foo.m
that contains a function called
foo can appear in all of these locations at the
same time. The conventions used on the Compiler command line are
documented in this table.
Name Description
foo.m
Default version of foo.m
xxx/private/foo.m
foo.m
private to the xxx directory