[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #48086] 2nd-level nested function not found in
From: |
John W. Eaton |
Subject: |
[Octave-bug-tracker] [bug #48086] 2nd-level nested function not found in anonymous function |
Date: |
Sun, 3 Mar 2019 19:36:37 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 |
Follow-up Comment #4, bug #48086 (project octave):
Rik: Thanks, I see it is attached now. I think the problem is that anonymous
functions are not (yet) proper closures and they are not properly grabbing all
the context necessary to execute outside of the scope where they are defined.
It works most of the time, but as you can see, when they call a nested
function the call stack is not right. I see that the following modification
does work:
function main
disp('main function')
a = 1;
nested(2)
function z = nested(x)
disp('nested')
z = a+x;
quad(@wrapper,z,1)
function y = nested2(x,a)
disp('nested2')
% here it does not work
y = a.*sin(x);
end
function r = wrapper (q)
r = nested2 (q, a);
end
end
end
Making anonymous functions behave more like a real nested functions should
solve this problem. In the meantime, it appears there are several ways to
work around it.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?48086>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/