help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: OO in octave.


From: Carnë Draug
Subject: Re: OO in octave.
Date: Mon, 4 Feb 2013 21:11:52 +0000

On 4 February 2013 20:42, ernst <address@hidden> wrote:
> Hi Carnë,
>> On 31 January 2013 12:26,  <address@hidden> wrote:
>>> Date: Thu, 31 Jan 2013 00:09:17 +0100
>>> From: ernst <address@hidden>
>>> To: address@hidden
>>> Subject: OO in octave.
>>> Message-ID: <address@hidden>
>>> Content-Type: text/plain; charset=ISO-8859-1
>>>
>>> Hi all,
>>> i know OO from java: x.function(a,....) means function(x,a,...)
>>> where the class of x determines the choice of the function.
>>>
>>> For octave i did not find an according statement in the docu.
>>> Does octave rely on the 1st argument only, as java does or does it look
>>> after all?
>> You can have both ways with Octave. Look at the inputParser class in
>> the general package for an example. Basically you'll need to play with
>> subsasgn and subsref.
> thank you for your answer.
> I found the general package but did not find the inputParser class.
> Maybe the problem is the version? I use 3.6.2.
> I searched all the loadpath. No success.

The general package has the inputParser class since version 1.3.0. The
current version is 1.3.2. Download the tarball here

http://octave.sourceforge.net/general/index.html

and look inside the inst/@inputParser directory.

> What I did is, to have a look at the documentation.
> I suspect that somewhere in my brain there is a deep misconception about
> OO in octave.
>
> I always thought, that subasgn and subsref refer to aspects of a single
> object,
> typically of its components,
> whereas i am talking about a list of parameters possibly consisting of
> many objects.
> Or does octave not distinguish between
> function (a,b,c) (3 elements) and function([a b c]) which is one only?

Basically you can can configure how indexing the object works. You can
use "()", "{}" or "." like you would for matrices, cells and
structures. Instead of using the dot for accessing a structure field,
you can use it to run methods. So you end up with the following syntax

obj.method (args)

It's not very complicated, look into the source of inputParser and we
might help you when you have specific questions.

Carnë


reply via email to

[Prev in Thread] Current Thread [Next in Thread]