octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #29456] class() should work for any method


From: Judd Storrs
Subject: [Octave-bug-tracker] [bug #29456] class() should work for any method
Date: Tue, 06 Apr 2010 19:40:29 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.8) Gecko/20100214 Ubuntu/9.10 (karmic) Firefox/3.5.8

URL:
  <http://savannah.gnu.org/bugs/?29456>

                 Summary: class() should work for any method
                 Project: GNU Octave
            Submitted by: judd
            Submitted on: Tue 06 Apr 2010 07:40:27 PM GMT
                Category: Interpreter
                Severity: 3 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

Octave prevents use of class() outside the constructor, however Matlab
appears to allow class() inside any method.

Consider:


@foo/foo.m:
function obj = foo()
  obj.data = 'Hello' ;
  obj = class(obj,'foo') ;

@foo/disp.m:
function disp(f)
   disp(struct(f))

@foo/bless.m:
function obj = bless(f,s)
  obj = class(s,'foo') ;


Matlab allows bless to convert any structure with the correct fields into a
foo-object.


>> a = foo()
a = 
        foo object: 1-by-1
>> disp(a)
    data: 'Hello'
>> b.data = 'World'
b = 
    data: 'World'
>> b = bless(a,b)
b = 
        foo object: 1-by-1
>> disp(b)
    data: 'World'


Octave refuses to allow class() outside of @foo/foo:


octave:1> a = foo()
a = <class foo>
octave:2> disp(a)
{
  data = Hello
}
octave:3> b.data = 'World'
b =
{
  data = World
}
octave:4> b = bless(a,b)
error: class: invalid call from outside class constructor
error: called from:
error:   /tmp/test3/@foo/bless.m at line 2, column 7






    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?29456>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

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