|
From: | Piotr Held |
Subject: | [Octave-bug-tracker] [bug #51599] Anonymous functions that reference local functions within classdef files don't work |
Date: | Thu, 27 Jul 2017 20:45:14 -0400 (EDT) |
User-agent: | Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36 |
URL: <http://savannah.gnu.org/bugs/?51599> Summary: Anonymous functions that reference local functions within classdef files don't work Project: GNU Octave Submitted by: jsoh425 Submitted on: Fri 28 Jul 2017 12:45:12 AM UTC Category: Interpreter Severity: 3 - Normal Priority: 5 - Normal Item Group: Incorrect Result Status: None Assigned to: None Originator Name: Piotr Held Originator Email: Open/Closed: Open Discussion Lock: Any Release: dev Operating System: Any _______________________________________________________ Details: If you create an anonymous function within a class method that references a local function the anonymous function will fail when executed. Even when called from within another class method. So with the following code: classdef local_classdef_anon_fcn < handle properties anon_fcn; end methods function foo (self) self.anon_fcn = @(x) my_helper(x+1); end function ret = bar (self, val) ret = self.anon_fcn (val); end end end function ret = my_helper (val) ret = val + 1; end When you call bar, the interpreter will not return with error: 'my_helper' undefined near line 7 column 30 -verbatim I am attaching a test case for this problem. If you were to simply reference 'my_helper' in any of the methods the code would work correctly. _______________________________________________________ File Attachments: ------------------------------------------------------- Date: Fri 28 Jul 2017 12:45:12 AM UTC Name: local_classdef_anon_fcn.m Size: 418B By: jsoh425 <http://savannah.gnu.org/bugs/download.php?file_id=41364> _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?51599> _______________________________________________ Message sent via/by Savannah http://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |