octave-bug-tracker
[Top][All Lists]
Advanced

[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/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]