|
From: | Robert T. Short |
Subject: | Re: OOP and load/save |
Date: | Thu, 23 Apr 2009 09:32:22 -0700 |
User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090402 SeaMonkey/1.1.16 |
John W. Eaton wrote:
OK. I tried another experiment. If I create a class and save it, then "clear classes", the class will "load" just fine.On 23-Apr-2009, Judd Storrs wrote: | ??? Error using ==> class | Number of fields for class Foo cannot be changed without clear classes. What if you just change the name of a field, but leave the number of fields the same? Does that also generate an error (I hope the answer is yes). | CLEAR CLASSES is the same as CLEAR ALL except that class definitions | are also cleared. If any objects exist outside the workspace (say in | userdata or persistent in a locked m-file) a warning will be issued and | the class definition will not be cleared. CLEAR CLASSES must be used if | the number or names of fields in a class are changed. Ah, OK. So we need to cache the fields (or just number of fields?) the first time a constructor is called, and compare field names on all subsequent constructor calls. I guess I can add that feature if someone else doesn't get to it before me. If anyone does decide to work on that, then please let me know. Thanks, jwe
If I exit MATLAB and then try to load the class from the file I get the same error that Judd saw.
Ergo, it appears that MATLAB stores the class structure even through a clear classes command. MATLAB does seem to keep track of both the number and names of fields.
Do we really need to worry about converting to a structure? MATLAB does it, but that seems pretty useless to me. Maybe just issue an error. Although, perhaps if we derived "octave_class" from "octave_struct", it wouldn't be too hard? That would also take care of some of the "FIXME" items you have in ov_class.cc where code is the same between the two files.
I am perfectly willing to work on this since I have already made some changes here, but I am kind of slow - normally I can only do this for a few hours on the weekends. I agree that there will be some surgery so I would like to discuss major changes before I make them.
Bob
[Prev in Thread] | Current Thread | [Next in Thread] |