Octave classes

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Octave classes

Massimo Manghi
Hi guys

I wrote a message to this list days ago which admittedly wasn't very
well concocted and it went unanswered. I try with a more direct and
explicit question.

Is there somewhere some sort of implementation of a foundation class
library for Octave? I'm trying to convert my scripts to classes but it
seems methods like get, set, display need to be reimplemented every
time, even though they do the same function for most of my classes. In
other words: is there some class from which one could derive its own
classes having those basic methods already available with a default
functionality?

  thanks

  -- Massimo
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Octave classes

Juan Pablo Carbajal
On Tue, Oct 2, 2012 at 11:39 AM, Massimo Manghi <[hidden email]> wrote:

> Hi guys
>
> I wrote a message to this list days ago which admittedly wasn't very well
> concocted and it went unanswered. I try with a more direct and explicit
> question.
>
> Is there somewhere some sort of implementation of a foundation class library
> for Octave? I'm trying to convert my scripts to classes but it seems methods
> like get, set, display need to be reimplemented every time, even though they
> do the same function for most of my classes. In other words: is there some
> class from which one could derive its own classes having those basic methods
> already available with a default functionality?
>
>  thanks
>
>  -- Massimo
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://mailman.cae.wisc.edu/listinfo/help-octave

afaik, there is no inheritance in Octave classes. Only composition
(you can do a hack by having a dummy class with the basic methods and
all new classes call those by default... horrible if you ask me).

You can have a few .m that you copy to all your new classes if they
all do exactly the same.

I think, jwe will release classdef for octave in the near future. then
you will have all the object thingy stuff.


--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Octave classes

Jordi Gutiérrez Hermoso-2
On 2 October 2012 08:20, Juan Pablo Carbajal <[hidden email]> wrote:

> afaik, there is no inheritance in Octave classes.

Of course there is. Otherwise, what's the point of having classes at all?

    http://www.gnu.org/software/octave/doc/interpreter/Inheritance-and-Aggregation.html
    http://www.gnu.org/software/octave/doc/interpreter/Overloading-Objects.html

Octave currently only implements old-style Matlab classes. There's
some preliminary work for classdef, but it will probably take some
time to come to fruition, unless you help.

- Jordi G. H.
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Octave classes

Juan Pablo Carbajal
On Tue, Oct 2, 2012 at 2:28 PM, Jordi Gutiérrez Hermoso
<[hidden email]> wrote:

> On 2 October 2012 08:20, Juan Pablo Carbajal <[hidden email]> wrote:
>
>> afaik, there is no inheritance in Octave classes.
>
> Of course there is. Otherwise, what's the point of having classes at all?
>
>     http://www.gnu.org/software/octave/doc/interpreter/Inheritance-and-Aggregation.html
>     http://www.gnu.org/software/octave/doc/interpreter/Overloading-Objects.html
>
> Octave currently only implements old-style Matlab classes. There's
> some preliminary work for classdef, but it will probably take some
> time to come to fruition, unless you help.
>
> - Jordi G. H.

Thank you for removing a drop of my ocean of ignorance!!

:D

--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Octave classes

Massimo Manghi
In reply to this post by Jordi Gutiérrez Hermoso-2
On 10/02/2012 02:28 PM, Jordi Gutiérrez Hermoso wrote:
> On 2 October 2012 08:20, Juan Pablo Carbajal<[hidden email]>  wrote:
>
>> afaik, there is no inheritance in Octave classes.
>
> Of course there is. Otherwise, what's the point of having classes at all?
>
>      http://www.gnu.org/software/octave/doc/interpreter/Inheritance-and-Aggregation.html
>      http://www.gnu.org/software/octave/doc/interpreter/Overloading-Objects.html
>

Thanks Jordi and Juan

so the bottom line is that for the time being I have to prepare myself
my own base class. Good to know.

Scripting an object systems almost certainly requires some degree of
introspection (the larger the better).

So I go back to the original question. I noticed a discrepancy between
the functions 'fieldnames' and 'isfield': 'fieldnames(...)' returns an
array of fields of a structure or a class, 'isfield(struct,field_name)'
doesn't know how to handle a class object and returns invariably 0, even
though it could be based on the former simply comparing each field in
the list returned by 'fieldnames' to the given field_name. This looks to
me like a bug or a missing feature...

 > Octave currently only implements old-style Matlab classes. There's
 > some preliminary work for classdef, but it will probably take some
 > time to come to fruition, unless you help.
 >
 > - Jordi G. H.

I have a decent experience programming C++ and I wrote a couple of C++
command extensions to Octave, but I never tweaked the core. So the
answer is yes, I could consider to help if you get me on the right track
(subscribing octave-dev? Contacting the person who is carrying on the
development of the object system?)

  -- Massimo
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Octave classes

Juan Pablo Carbajal
On Wed, Oct 3, 2012 at 10:10 AM, Massimo Manghi <[hidden email]> wrote:

> On 10/02/2012 02:28 PM, Jordi Gutiérrez Hermoso wrote:
>>
>> On 2 October 2012 08:20, Juan Pablo Carbajal<[hidden email]>  wrote:
>>
>>> afaik, there is no inheritance in Octave classes.
>>
>>
>> Of course there is. Otherwise, what's the point of having classes at all?
>>
>>
>> http://www.gnu.org/software/octave/doc/interpreter/Inheritance-and-Aggregation.html
>>
>> http://www.gnu.org/software/octave/doc/interpreter/Overloading-Objects.html
>>
>
> Thanks Jordi and Juan
>
> so the bottom line is that for the time being I have to prepare myself my
> own base class. Good to know.
>
> Scripting an object systems almost certainly requires some degree of
> introspection (the larger the better).
>
> So I go back to the original question. I noticed a discrepancy between the
> functions 'fieldnames' and 'isfield': 'fieldnames(...)' returns an array of
> fields of a structure or a class, 'isfield(struct,field_name)' doesn't know
> how to handle a class object and returns invariably 0, even though it could
> be based on the former simply comparing each field in the list returned by
> 'fieldnames' to the given field_name. This looks to me like a bug or a
> missing feature...
>
>
>> Octave currently only implements old-style Matlab classes. There's
>> some preliminary work for classdef, but it will probably take some
>> time to come to fruition, unless you help.
>>
>> - Jordi G. H.
>
> I have a decent experience programming C++ and I wrote a couple of C++
> command extensions to Octave, but I never tweaked the core. So the answer is
> yes, I could consider to help if you get me on the right track (subscribing
> octave-dev? Contacting the person who is carrying on the development of the
> object system?)
>
>  -- Massimo

Regarding the right track.

There the IRC channel, where you can find jwe
irc.freenode.net
chat room #octave

The correct mailing list and other resources are marked here.
http://www.gnu.org/software/octave/get-involved.html

If you find help missing and you think it may make the entry to other
developers easy, please update the wiki
wiki.octave.org

Looking forward!

--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|

Re: Octave classes

Massimo Manghi
On 10/03/2012 10:29 AM, Juan Pablo Carbajal wrote:
  > Regarding the right track.

>
> There the IRC channel, where you can find jwe
> irc.freenode.net
> chat room #octave
>
> The correct mailing list and other resources are marked here.
> http://www.gnu.org/software/octave/get-involved.html
>
> If you find help missing and you think it may make the entry to other
> developers easy, please update the wiki
> wiki.octave.org
>
> Looking forward!
>

great, thanks a lot

  -- Massimo
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave