[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OO in octave.
From: |
Julien Bect |
Subject: |
Re: OO in octave. |
Date: |
Thu, 31 Jan 2013 07:55:46 -0800 (PST) |
Ernst Reissner wrote
> I just wondered, whether octave checks for the first argument only.
> And i was confused, that i did nowhere in the docu find a word about the
> search mechanism.
> Something like:
> "If the first argument arg1 has class
> <cls>
> (determined by function
> class(arg1)),
> then the function definition is searched for in folder @
> <cls>
> and
> subfolders recursively. "
>
> Is this the truth?
Hello Ernst,
No, it's not the truth... An overloaded function can be called if any of
the arguments, /regardless of its position/, is an object.
If several arguments are objects, then the appropriate function is chosen
based on a *precedence* mechanism :
http://www.gnu.org/software/octave/doc/interpreter/Precedence-of-Objects.html#Precedence-of-Objects
<http://www.gnu.org/software/octave/doc/interpreter/Precedence-of-Objects.html#Precedence-of-Objects>
Even if an argument is of class "cls", the function that is called is not
necessarily in @cls because of the *inheritance* mechanism (it might be in
the @ folder of the parent class, if the required function is not overloaded
by cls but is defined or overloaded by the parent class).
http://www.gnu.org/software/octave/doc/interpreter/Inheritance-and-Aggregation.html#Inheritance-and-Aggregation
<http://www.gnu.org/software/octave/doc/interpreter/Inheritance-and-Aggregation.html#Inheritance-and-Aggregation>
I'm not sure about how precedence and inheritance interact, though...
Julien.
--
View this message in context:
http://octave.1599824.n4.nabble.com/OO-in-octave-tp4649299p4649322.html
Sent from the Octave - General mailing list archive at Nabble.com.