octave-maintainers
[Top][All Lists]
Advanced

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

Re: OOP load update


From: Judd Storrs
Subject: Re: OOP load update
Date: Tue, 5 May 2009 23:44:13 -0400

I'm pretty sure the constructor is called if Matlab doesn't have a class definition. Suppose:

@FooBar/FooBar.m:
function obj = FooBar()
     disp('Hello!');
     obj.data = "">      obj = class(obj, 'FooBar');

Then at least in Matlab R14 (7.0.1) (I've edited whitespace):

Matlab Session 1:
>> obj1 = FooBar()
Hello!
obj1 = FooBar object: 1-by-1
>> save('test.mat','obj1')
>> obj2 = FooBar()        
Hello!
obj2 = FooBar object: 1-by-1
>> save('test2.mat','obj2')
>> exit

Matlab Session 2:
>> load test.mat
Hello!
>> load test2.mat
>>

As you see in the second session, matlab does execute the constructor the first time it encounters the FooBar class, but once it knews the class structure, it didn't need to call the constructor again.

--judd


reply via email to

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