function topLevelFunction() % Helper anonymous function - used to pack/unpack design variables in actual code. unpacker = @(x) sum( x ); % Optimisation objective function - required soem other data passed through % using anonymous function in call to solver. function [ x ] = objFcn( x , a ) x = a + unpacker( x ); end % function nf % Dummy solver - actually using leasqr. function [ y ] = solver( funcHandle ) % Solver determine design values. x = [ 2 , 3 ]; % Call objective function to get value. y = funcHandle( x ); end % function % Fixed data needed by objective function. Actually a heap of stuff requiring % complex calculation. a = 1; % Call optmiser. % Octave 5.2.0, as shipped on Ubuntu 20.04 - OK. % Octave 6.1.0, self compiled - FAIL: % error: ‘unpacker’ undefined near line 10, column 10 % error: called from % topLevelFunction>objFcn at line 10 column 7 % topLevelFunction>@ at line 38 column 20 % topLevelFunction>solver at line 21 column 7 % topLevelFunction at line 38 column 5 y = solver( @(x) objFcn( x , a ) ) end % function topLevelFunction