octave-maintainers
[Top][All Lists]
Advanced

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

Re: Classdef embryonic support


From: Ben Abbott
Subject: Re: Classdef embryonic support
Date: Sat, 12 Jan 2013 19:02:31 -0500

On Jan 12, 2013, at 11:54 AM, Michael Goffioul wrote:

> On Sat, Jan 12, 2013 at 11:34 AM, Ben Abbott <address@hidden> wrote:
> On Jan 6, 2013, at 10:35 PM, Michael Goffioul wrote:
> 
> > On Tue, Jan 1, 2013 at 8:09 PM, Michael Goffioul <address@hidden> wrote:
> > Hi,
> >
> > Just a heads up to let people know I've spent some time during my christmas 
> > holiday to start working again on the classdef branch. I've just pushed 
> > some changes to implement initial support for handle-class and value-class 
> > semantic. Don't expect too much out of it, but maybe some of you are 
> > interested in giving it a try. For instance, I'd be more than happy if 
> > someone would write unit tests for the classdef support.
> >
> > Did anybody have a chance to give it a try? Although far from finished, 
> > it's already somehow usable (you can define classes, methods, properties, 
> > use inheritance and make superclass calls; it also supports handle and 
> > value semantics).
> >
> > Michael.
> 
> The classef branch now builds on MacOS X! :-)
> 
> I'm new to classdef, so I borrowed an example from the Mathworks site, made 
> some modifications, and added some tests (see the attached payment.m)
> 
> However, I'm not sure how to go about adding tests to the sources.  Perhaps 
> syntax like below be added to the test feature?
> 
> %!classdef payment
> %!   properties
> %!     rate;
> %!     term;
> %!     principle;
> %!   end
> %!   methods
> %!     function obj = payment (r, t, p)
> %!       obj.rate = r;
> %!       obj.term = t;
> %!       obj.principle = p;
> %!     end
> %!     function amt = amount (obj)
> %!       i = obj.rate / (12 * 100);
> %!       amt = (obj.principle * i) / (1 - (1 + i)^(-obj.term));
> %!     end
> %!   end
> %!endclassdef
> 
> For now, tests can be added to a classdef m-file, but I don't see how that 
> would be committed.
> 
> See how tests are designed for the old-style class in test/classes/.

That's simple enough.  I've attached a changeset with some basic tests.  Look 
ok?

> Thanks for giving it a try, Ben. I'm fully aware of the limitations and all 
> these are on my (huge) TODO list. At the moment, what is supported is:
> - classdef file parsing
> - handle/value class semantic
> - class inheritance
> - property/method access with dot-notation
> - property/method access restriction (public, protected, private, cell array 
> of classes)
> - property accessors
> - array of objects(not complete, though)
> 
> Michael.

I'll start tinkering more with classdef.   As I come up to speed, I'll add more 
tests.

Ben

Attachment: changeset.patch
Description: Binary data


reply via email to

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