[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #32964] Inheritance and anonymous functions do
From: |
Patrick Häcker |
Subject: |
[Octave-bug-tracker] [bug #32964] Inheritance and anonymous functions do not work together |
Date: |
Thu, 31 Mar 2011 11:12:55 +0000 |
User-agent: |
Mozilla/5.0 (compatible; Konqueror/4.4; de) KHTML/4.4.5 (like Gecko) |
URL:
<http://savannah.gnu.org/bugs/?32964>
Summary: Inheritance and anonymous functions do not work
together
Project: GNU Octave
Submitted by: magicmuscleman
Submitted on: Do 31 Mär 2011 11:12:54 GMT
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Crash
Status: None
Assigned to: None
Originator Name: Debian 6.0
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 3.4.0
Operating System: GNU/Linux
_______________________________________________________
Details:
There is a problem in Octave with the combination of inherited objects and the
usage of anonymous functions/methods, which works with Matlab. It's probably
best to give an example:
Assume there is a class "Parent":
Constructor:
function parent = Parent()
parent = class(struct(), 'Parent');
end
Method:
function parentMethod(parent)
disp(['This is a method of class Parent called with an object of class '
class(parent)]);
end
Assume there is another class "Child" which inherits from "Parent":
Constructor:
function child = Child()
child = class(struct(), 'Child', Parent());
end
Now we want to test our two classes:
function testInheritance()
% This works in Matlab and in Octave
child = Child();
parentMethod(child);
% This works, too
parent = Parent();
fun = @() parentMethod(parent);
fun();
% This works in Matlab but _not_ in Octave
fun = @() parentMethod(child);
fun();
end
The result of this test is:
This is a method of class Parent called with an object of class Child
This is a method of class Parent called with an object of class Parent
error: parentMethod: no method for class Child
So as you can see, the call of the parent method fails for inherited objects
when using an anonymous function. Thus it's not possible to use higher order
functions with inheritance in Octave.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Do 31 Mär 2011 11:12:54 GMT Name: testInheritance.tar Size: 6kB By:
magicmuscleman
<http://savannah.gnu.org/bugs/download.php?file_id=23063>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?32964>
_______________________________________________
Nachricht geschickt von/durch Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #32964] Inheritance and anonymous functions do not work together,
Patrick Häcker <=