On this page that explains the use of inputParser
class,
we see that every inputParser
method call in the examples is of the form
methodname(object, arguments)
instead of
object.methodname(arguments)
For example
addRequired(p,'filename',@ischar)
instead of
p.addRequired('filename',@ischar)
where p
is an instance if inputParser
.
I would say that this makes it unclear where addRequired
is coming from without having to search for it either though which
or for the instantiation line in the code before it is being called. Having addRequired
available in any context kind of breaks encapsulation, and seems to be the very opposite of what you would want from introducing OOP in the first place.
I suspect there is a good reason to sacrifice readability and write documentation in this particular way.
So my question is, is there any practical difference between "functional" and "OOP" syntax in MATLAB?