[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous func
From: |
Denis Sbragion |
Subject: |
[Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling |
Date: |
Tue, 16 Mar 2021 07:11:42 -0400 (EDT) |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0 |
Follow-up Comment #5, bug #60237 (project octave):
Hello,
I think I nailed down the problem. I started from the textbook example at:
https://octave.org/doc/v6.2.0/Calling-Octave-Functions-from-Oct_002dFiles.html#Calling-Octave-Functions-from-Oct_002dFiles
and compared it to the NLOpt Octave interface. In the end it all boils down to
the following situation:
#include <octave/oct.h>
#include <octave/parse.h>
DEFMETHOD_DLD (callback, interp, args, nargout, "Callback Demo")
{
int nargin = args.length ();
if (nargin < 2)
print_usage ();
octave_value_list newargs;
for (octave_idx_type i = nargin - 1; i > 0; i--)
newargs(i-1) = args(i);
octave_value_list retval;
// Works
retval = interp.feval (args(0), newargs, nargout);
// Fails
retval = interp.feval (args(0).function_value(), newargs, nargout);
return retval;
}
This trivial callback function has to be called passing an anonymous function
with context inherited parameters like in the antest() example to see the
problem happening.
The NLOpt interface uses some more convoluted code which is equivalent to the
failing one above. I don't know if there has been some API change which
forbids the second type of call in 6.X. If this is the case I'll fix the NLOpt
interface and warn back the NLOpt developers.
Let me know.
Bye,
Denis Sbragion
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?60237>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, Denis Sbragion, 2021/03/15
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, Dmitri A. Sergatskov, 2021/03/15
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, Markus Mützel, 2021/03/15
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, Denis Sbragion, 2021/03/16
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, Denis Sbragion, 2021/03/16
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling,
Denis Sbragion <=
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, Markus Mützel, 2021/03/17
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, Denis Sbragion, 2021/03/17
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, Denis Sbragion, 2021/03/18
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, Denis Sbragion, 2021/03/18
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, Denis Sbragion, 2021/03/22
- [Octave-bug-tracker] [bug #60237] Differente behaviour in anonymous function handling, John W. Eaton, 2021/03/22