Mercurial > hg > octave-terminal
changeset 12946:8b5b85e26246 stable
octave-parse.yy (feval): Update docstring to refer to function handles.
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Thu, 11 Aug 2011 01:46:06 -0500 |
parents | 0c74237b3479 |
children | 93a1d99183fb |
files | src/oct-parse.yy |
diffstat | 1 files changed, 20 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -4223,12 +4223,26 @@ @noindent\n\ calls the function @code{acos} with the argument @samp{-1}.\n\ \n\ -The function @code{feval} is necessary in order to be able to write\n\ -functions that call user-supplied functions, because Octave does not\n\ -have a way to declare a pointer to a function (like C) or to declare a\n\ -special kind of variable that can be used to hold the name of a function\n\ -(like @code{EXTERNAL} in Fortran). Instead, you must refer to functions\n\ -by name, and use @code{feval} to call them.\n\ +The function @code{feval} can also be used with function handles of\n\ +any sort. @xref{Function Handles} Historically, @code{feval} was\n\ +the only way to call user-supplied functions in strings, but\n\ +function handles are now preferred due to the cleaner syntax they\n\ +offer. For example,\n\ +\n\ +@example\n\ +@group\n\ +@var{f} = @@exp;\n\ +feval (@var{f}, 1)\n\ + @result{} 2.7183\n\ +@var{f} (1)\n\ + @result{} 2.7183\n\ +@end group\n\ +@end example\n\ +\n\ +@noindent\n\ +are equivalent ways to call the function referred to by @var{f}. If it\n\ +cannot be predicted beforehand that @var{f} is a function handle or the\n\ +function name in a string, @code{feval} can be used instead.\n\ @end deftypefn") { octave_value_list retval;