octave-maintainers
[Top][All Lists]
Advanced

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

Re: [classdef] Can someone test this for me?


From: Michael Goffioul
Subject: Re: [classdef] Can someone test this for me?
Date: Tue, 15 Oct 2013 22:11:02 -0400

On Tue, Oct 15, 2013 at 10:04 PM, Ben Abbott <address@hidden> wrote:

On Oct 15, 2013, at 8:53 PM, Michael Goffioul wrote:

> On Tue, Oct 15, 2013 at 6:38 PM, Michael Goffioul <address@hidden> wrote:
> On Tue, Oct 15, 2013 at 2:58 PM, Michael Goffioul <address@hidden> wrote:
> On Tue, Oct 15, 2013 at 2:06 PM, Серёжа Плотников <address@hidden> wrote:
> New ML Session:
>
> >> x = classderiv
> x =
>   classderiv with no properties.
> >> x.fun
> ans =
>      0
> >> addpath a
> >> x.fun
> ans =
>      0
> >> y = classderiv
> y =
>   classderiv with no properties.
> >> y.fun
> ans =
>      0
>
> Thank you. I appreciate your help. Those results are not exactly those I expected, so I'll ask you to run a few more tests.
>
> Can you re-run the session above, but start with addpath, that is:
>
> addpath a
> x = classderiv
> x.fun
>
> Then edit classbase.m and remove the "Sealed" attribute and run the 2 sessions (make sure to restart Matlab between each session);
>
> x = classderiv
> x.fun
> addpath a
> x.fun
> y = classderiv
> y.fun
>
> addpath a
> x = classderiv
> x.fun
>
> Depending on the results, I may ask you (or if anyone else wants to do it) to run some more tests.
>
> Can anybody run these tests for me? That would help clearing out a few gray zones.
>
> Carne Draug has kindly run the test on IRC for me. There's still one thing I'd like to have tested to confirm my suspicion.
>
> Consider the following file/directory structure (assuming "a" and "b" are not automatically in Matlab path):
>
> a/classbase.m:
> classdef classbase
>   methods
>     function y = fun (obj)
>       y = 0;
>     end
>   end
> end
>
> a/@classderiv/classderiv.m:
> classdef classderiv < classbase
> end
>
> a/@classderiv/fun.m:
> function y = fun (obj)
>   y = 1;
> end
>
> b/@classderiv/fun2.m:
> function y = fun2 (obj)
>   y = 2;
> end
>
> Then at Matlab prompt:
>
> addpath b
> addpath a
> x = classderiv
> x.fun
> x.fun2
>
> Thanks,
> Michael.

x =

  classderiv with no properties.


ans =

     1

No appropriate method, property, or field fun2 for class classderiv.

Thanks, Ben.

So the bottom-line seems to be that for classdef classes defined in @-folder, Matlab only looks for methods-defined-in-external-files in the @-directory where the classdef m-file is located. This is rather different than old-style classes, where methods can be spread among various @-folders, and the existence of methods is then sensitive to the path.

Ben, could you also try the other method-call syntax, to check whether the result is the same (I sincerely hope it is...):

fun(x)
fun2(x)

Thanks,
Michael.


reply via email to

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