[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #35448] parser problems with nested anonymous
From: |
Ben Abbott |
Subject: |
[Octave-bug-tracker] [bug #35448] parser problems with nested anonymous functions |
Date: |
Sat, 04 Feb 2012 19:23:15 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.77 Safari/535.7 |
URL:
<http://savannah.gnu.org/bugs/?35448>
Summary: parser problems with nested anonymous functions
Project: GNU Octave
Submitted by: bpabbott
Submitted on: Sat 04 Feb 2012 02:23:14 PM EST
Category: Interpreter
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Ben Abbott
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: dev
Operating System: Any
_______________________________________________________
Details:
With each function in its own m-file
# fA.m
function y = fA (x, f)
global gfun
if nargin < 2
y = fA (x, gfun);
else
w = feval (f, x)
y = feval (@fB, w);
endif
endfunction
# fB.m
function y = fB (x)
y = x;
endfunction
# fC.m
function y = fC (x)
y = x;
endfunction
Running the script below, or typing the commands at the prompt produces the
proper result.
clear all
global gfun
gfun = @fB;
y = fA (e)
The proper result is
foo
w = 2.7183
y = 2.7183
The modified version below (@fC instead of @fB) throws an error.
clear all
global gfun
gfun = @fC;
y = fA (e)
The error is
w = 2.7183
error: `w' undefined near line 7 column 21
error: evaluating argument list element number 2
Notice that in fA.m `w' evaluates to the proper result.
fB and fC are intentionally identical, and there is no problem if the global
variable isn't used.
I've attached the files. foo.m is a script that runs the working and failing
example.
_______________________________________________________
File Attachments:
-------------------------------------------------------
Date: Sat 04 Feb 2012 02:23:14 PM EST Name: Archive.zip Size: 780B By:
bpabbott
<http://savannah.gnu.org/bugs/download.php?file_id=24981>
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?35448>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #35448] parser problems with nested anonymous functions,
Ben Abbott <=