|
From: | John W. Eaton |
Subject: | [Octave-bug-tracker] [bug #45835] wrong scope may be used in anonymous function evaluation |
Date: | Fri, 28 Aug 2015 20:02:18 +0000 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0 Iceweasel/38.1.0 |
Update of bug #45835 (project octave): Summary: interpreter does not search for anonymous function variables within a string => wrong scope may be used in anonymous function evaluation _______________________________________________________ Follow-up Comment #5: I'm retitling this report. Note the difference in the following: f = @() __current_scope__ g = @() eval ('__current_scope__') f() g() The trouble is caused by this function: http://hg.savannah.gnu.org/hgweb/octave/annotate/2f94652de9ff/libinterp/octave-value/ov-fcn-handle.cc#l1945 I believe the purpose of the octave_fcn_binder object is to optimize things like @f(x) sin (x) so that they are almost as efficient as calling the internal function directly instead of going through all the effort of evaluating a user-defined function simply to call another function or simple expression. You can show that the problem disappears if you make the body of the octave_fcn_binder::maybe_binder function be return new octave_fcn_handle (f, octave_fcn_handle::anonymous); I'm looking to see whether there is a simple fix that will preserve this optimization and make the eval case work properly. _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?45835> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |