[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Some OOP questions
From: |
Judd Storrs |
Subject: |
Re: Some OOP questions |
Date: |
Thu, 9 Feb 2012 17:44:05 -0500 |
On Thu, Feb 9, 2012 at 5:01 PM, CdeMills <address@hidden> wrote:
> I understand the concept of wildcard method, but what would be "subclassing
> a builtin" ?
What I mean is creating a new class by extending a builtin type. Like:
@foo/foo.m
function f = foo(p)
p = double(p);
f.meta = struct();
f = class(f,"foo",p);
endfunction
Then class foo would behave just like a double array/matrix except for
methods that explicitly add or override that behavior. So in that
example, @foo would just inherit all the functions that already would
be called if the first argument was a double. You could use that to
create a matrix that used degrees instead of radians for trig
functions, for example.
--judd