[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
parsing problem with OOP?
From: |
Ben Abbott |
Subject: |
parsing problem with OOP? |
Date: |
Wed, 17 Nov 2010 07:56:44 -0500 |
Using the developer's sources I see a parsing problem for objects constructed
with properties which are structures.
Consider the simple class defintion ...
--------------------
function p = foobar ()
p = struct ();
p.s.words = {"Hello", "World"};
p = class (p, "foobar");
endfunction
--------------------
... with two overloaded functions ...
--------------------
function display (obj)
printf ("%s ", obj.s.words{:})
printf ("\b.\n")
endfunction
--------------------
--------------------
function v = subsref (obj, prop)
try
ok = strcmp (prop.type, ".");
disp ("Reference to struct property worked.")
catch
type = prop.type;
subs = prop.subs;
ok = strcmp (type, ".");
disp ("Reference to struct property failed.")
end_try_catch
if (ok)
v = builtin ("subsref", obj, prop);
else
error ("foobar:invalidsubsref",
"Invalid subsref for property of 'foobar' object.")
endif
endfunction
--------------------
Accessing "s" works. However, direct access to "words" fails.
octave:1> f = foobar
Hello World.
octave:2> s = f.s
Reference to struct property worked.
s =
{
words =
{
[1,1] = Hello
[1,2] = World
}
}
octave:3> f.s.words
Reference to struct property failed.
ans =
{
[1,1] = Hello
[1,2] = World
}
octave:4> lasterr
ans = Invalid call to strcmp. Correct usage is:
-- Built-in Function: strcmp (S1, S2)
Before I submit a bug report, is this a bug?
Ben
- parsing problem with OOP?,
Ben Abbott <=