Wed 01 Feb 2017 01:30:34 AM UTC, comment #6:
I replaced the possible feval calls in libinterp with direct calls to C++ function in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/35e3d199527c). Closing report.
|
Tue 24 Jan 2017 05:20:14 PM UTC, comment #5:
Yes, you can call the built-in functions directly in some cases. But we should not do that when it is possible to use liboctave functions directly. For example, we shouldn't be packing matrix objects inside octave_value{,_list} objects just so Fsum can unpack them, then compute the sum, then put them back in octave_value{,_list} objects so we can unpack them again.
|
Tue 24 Jan 2017 05:03:59 PM UTC, comment #4:
Another note, looking in the list of instances that I got from grep'ing the code, this instance should not be replaced
This is executing a callback function which is held in the variable "fcn". This instance needs to continue using feval.
|
Tue 24 Jan 2017 04:56:02 PM UTC, comment #3:
The second argument is the number of output arguments (nargout). For the function "sum", there is only one output. But a function like "sort" might have two outputs.
I hadn't gotten around to it but this is exactly the way I was going to proceed. Add
to the top of the files that need it, and then replace
with
|
Tue 24 Jan 2017 09:02:47 AM UTC, comment #2:
The example of comment #1 is bad, as "isequal" is a pure M-file. Another example:
Before:
After:
|
Tue 24 Jan 2017 08:52:58 AM UTC, comment #1:
A remedy could be the following pattern to refactor the code:
Before:
After:
The remedy is inspired by "examples/code/standalonebuiltin.cc". This compiles for me (I am currently working on bug #50105 but decided to post here for generality). Now I want to know if this approach is desired and what does the "1" in the end of Fisequal (args, 1) mean? In "libinterpreter/builtin-defun-decls.h" it is "0" by default. Is there any documentation available? The file "libinterpreter/builtin-defun-decls.h" is generated by the undocumented "build-aux/mk-builtins.pl".
|
Sat 21 Jan 2017 11:07:17 PM UTC, original submission:
Within C++, interpreter functions written in C++ like "sum" can be called directly using the name with 'F' prepended. For example, "Fsum" or "Flasterr". However, the code often makes use of feval to do this instead.
Whenever the function name might be overloaded in the symbol table, such as with display for class objects, then the invocation implementation needs to remain as feval. However, the rest of the time these could be
Examples:
See the related bug #50105.
|