User`s guide
5 Controlling Code Generation
5-6
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 i n 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.
Inorder tocompileamethodfunction,youmustspecifythe nameofthemethod
along with the classname so that the Compiler can differentiate the method
function from a nonmethod (normal) function.
Note Although Compiler 2.1 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 as
documented in this table.
Name Description
foo.m
Default version of foo.m
xxx/private/foo.m
foo.m
privatetothexxx directory
@cell/foo.m
foo.m
method to operate on cell arrays
@cell/private/foo.m
foo.m private to methods that operate on
cell arrays