Problem with scoping rules of sub-functions used as function handles in 3.0.x and 3.1.x

David Bateman David.Bateman at motorola.com
Thu Jun 12 08:28:59 CDT 2008


Consider the piece of code

function [g,h] = test_fhandle ()
  g = @(x) func2 (x);
  h = func1 ();
end
function h = func1 ()
  h = @(x) func2 (x);
end
function y = func2 (x)
  y = x;
end

and then run "[g, h] = test_fhandle". Under matlab g(1) and h(1) both
return the function evaluation. However in 3.0.1 "h(1)" fails as "func2"
is not in the scope of the handle even though clearly it is in the scope
of func1 above where the handle is defined. Something similar happens in
3.1.x though "func2" doesn't appear to be defined in either of the
returned function handles.. I have some code that would be simplified if
this worked correctly.

D.

-- 
David Bateman                                David.Bateman at motorola.com
Motorola Labs - Paris                        +33 1 69 35 48 04 (Ph) 
Parc Les Algorithmes, Commune de St Aubin    +33 6 72 01 06 33 (Mob) 
91193 Gif-Sur-Yvette FRANCE                  +33 1 69 35 77 01 (Fax) 

The information contained in this communication has been classified as: 

[x] General Business Information 
[ ] Motorola Internal Use Only 
[ ] Motorola Confidential Proprietary



More information about the Bug-octave mailing list