[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Octave Classes Usage
From: |
David Grundberg |
Subject: |
Re: Octave Classes Usage |
Date: |
Fri, 25 Jun 2010 09:38:25 +0200 |
User-agent: |
Thunderbird 2.0.0.24 (X11/20100411) |
Pablo Daniel Pareja Obregon skrev:
> Hi everyone,
>
> I'm trying to use octave class function to define my own structure to hold
> properties and data. I searched for examples on the web, and what I found so
> far is something like this:
>
> @foo/foo.m:
> function obj = foo()
> obj.name = "foo" ;
> obj = class(obj, "foo") ;
>
> However, when invoking x = foo() from the command line typeinfo(x) returns
> "class" when it should be "foo".
typeinfo is used to debug the interpreter. Use class (x) to determine
the object's class.
> After creating x, if I try to access any
> fields (for example issuing the command x.name), I get the following error:
>
> error: invalid index for class
No, callers don't have access to the class fields. They are private and
can only be accessed from methods.
>
> Finally, if I try to modify any field in x (x.name = "John"), octave crashes.
> with the following message:
>
> panic: Segmentation fault -- stopping myself...
> attempting to save variables to `octave-core'...
> save to `octave-core' complete
> Segment fault
>
Segfaults, that's a bug. But again, you cannot access fields from
outside methods.
> I am currently using Debian Testing, and my octave version is 3.2.4-4.
>
> Am I using the class in the correct way? Is it a bug? Thanks in advance.
>
> Regards,
> Pablo
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
- Octave Classes Usage, Pablo Daniel Pareja Obregon, 2010/06/24
- Re: Octave Classes Usage,
David Grundberg <=