# HG changeset patch # User jwe # Date 943205470 0 # Node ID 86873384cd10c81f8ee86cf8a2a8a6baa028fcc9 # Parent 0b88d26ed5527619bb18ea8fd46f947b9f41c033 [project @ 1999-11-21 17:31:07 by jwe] diff --git a/doc/interpreter/eval.txi b/doc/interpreter/eval.txi --- a/doc/interpreter/eval.txi +++ b/doc/interpreter/eval.txi @@ -16,61 +16,11 @@ are not known until run time, or to write functions that will need to call user-supplied functions. -@deftypefn {Built-in Function} {} eval (@var{command}) -Parse the string @var{command} and evaluate it as if it were an Octave -program, returning the last value computed. The @var{command} is -evaluated in the current context, so any results remain available after -@code{eval} returns. For example, - -@example -@group -eval ("a = 13") - @print{} a = 13 - @result{} 13 -@end group -@end example - -In this case, the value of the evaluated expression is printed and it is -also returned returned from @code{eval}. Just as with any other -expression, you can turn printing off by ending the expression in a -semicolon. For example, - -@example -eval ("a = 13;") - @result{} 13 -@end example +@DOCSTRING(eval) -In this example, the variable @code{a} has been given the value 13, but -the value of the expression is not printed. You can also turn off -automatic printing for all expressions executed by @code{eval} using the -variable @code{default_eval_print_flag}. -@end deftypefn - -@defvr {Built-in Variable} default_eval_print_flag -If the value of this variable is nonzero, Octave prints the results of -commands executed by @code{eval} that do not end with semicolons. If it -is zero, automatic printing is suppressed. The default value is 1. -@end defvr - -@deftypefn {Built-in Function} {} feval (@var{name}, @dots{}) -Evaluate the function named @var{name}. Any arguments after the first -are passed on to the named function. For example, +@DOCSTRING(default_eval_print_flag) -@example -feval ("acos", -1) - @result{} 3.1416 -@end example - -@noindent -calls the function @code{acos} with the argument @samp{-1}. - -The function @code{feval} is necessary in order to be able to write -functions that call user-supplied functions, because Octave does not -have a way to declare a pointer to a function (like C) or to declare a -special kind of variable that can be used to hold the name of a function -(like @code{EXTERNAL} in Fortran). Instead, you must refer to functions -by name, and use @code{feval} to call them. -@end deftypefn +@DOCSTRING(feval) Here is a simple-minded function using @code{feval} that finds the root of a user-supplied function of one variable using Newton's method. diff --git a/doc/interpreter/expr.txi b/doc/interpreter/expr.txi --- a/doc/interpreter/expr.txi +++ b/doc/interpreter/expr.txi @@ -45,12 +45,7 @@ @code{do_fortran_indexing} is nonzero, in which case matrices may also be indexed by a single expression. -@defvr {Built-in Variable} do_fortran_indexing -If the value of @code{do_fortran_indexing} is nonzero, Octave allows -you to select elements of a two-dimensional matrix using a single index -by treating the matrix as a single vector created from the columns of -the matrix. The default value is 0. -@end defvr +@DOCSTRING(do_fortran_indexing) Given the matrix @@ -108,6 +103,8 @@ practice, you may select the behavior you prefer by setting the built-in variable @code{prefer_zero_one_indexing}. +@c XXX FIXME XXX -- this variable no longer exists! + @defvr {Built-in Variable} prefer_zero_one_indexing If the value of @code{prefer_zero_one_indexing} is nonzero, Octave will perform zero-one style indexing when there is a conflict with the @@ -170,41 +167,9 @@ size whose elements are all one, and then to scale it to produce the desired result. @xref{Special Utility Matrices}. -@defvr {Built-in Variable} prefer_column_vectors -If @code{prefer_column_vectors} is nonzero, operations like - -@example -for i = 1:10 - a (i) = i; -endfor -@end example - -@noindent -(for @code{a} previously undefined) produce column vectors. Otherwise, row -vectors are preferred. The default value is 1. - -If a variable is already defined to be a vector (a matrix with a single -row or column), the original orientation is respected, regardless of the -value of @code{prefer_column_vectors}. -@end defvr +@DOCSTRING(prefer_column_vectors) -@defvr {Built-in Variable} resize_on_range_error -If the value of @code{resize_on_range_error} is nonzero, expressions -like - -@example -for i = 1:10 - a (i) = sqrt (i); -endfor -@end example - -@noindent -(for @code{a} previously undefined) result in the variable @code{a} -being resized to be just large enough to hold the new value. New -elements that have not been given a value are set to zero. If the value -of @code{resize_on_range_error} is 0, an error message is printed and -control is returned to the top level. The default value is 1. -@end defvr +@DOCSTRING(resize_on_range_error) Note that it is quite inefficient to create a vector using a loop like the one shown in the example above. In this particular case, it would @@ -417,13 +382,7 @@ The built-in variable @code{max_recursion_depth} specifies a limit to the recursion depth and prevents Octave from recursing infinitely. -@defvr max_recursion_depth -Limit the number of times a function may be called recursively. -If the limit is exceeded, an error message is printed and control -returns to the top level. - -The default value is 256. -@end defvr +@DOCSTRING(max_recursion_depth) @node Arithmetic Ops, Comparison Ops, Calling Functions, Expressions @section Arithmetic Operators @@ -585,11 +544,7 @@ preferring the longest possible match at any given point, it is more useful in this case. -@defvr {Built-in Variable} warn_divide_by_zero -If the value of @code{warn_divide_by_zero} is nonzero, a warning -is issued when Octave encounters a division by zero. If the value is -0, the warning is omitted. The default value is 1. -@end defvr +@DOCSTRING(warn_divide_by_zero) @node Comparison Ops, Boolean Expressions, Arithmetic Ops, Expressions @section Comparison Operators diff --git a/doc/interpreter/func.txi b/doc/interpreter/func.txi --- a/doc/interpreter/func.txi +++ b/doc/interpreter/func.txi @@ -227,30 +227,9 @@ were passed to Octave. @end defvr -@defvr {Built-in Variable} silent_functions -If the value of @code{silent_functions} is nonzero, internal output -from a function is suppressed. Otherwise, the results of expressions -within a function body that are not terminated with a semicolon will -have their values printed. The default value is 0. - -For example, if the function +@DOCSTRING(silent_functions) -@example -function f () - 2 + 2 -endfunction -@end example - -@noindent -is executed, Octave will either print @samp{ans = 4} or nothing -depending on the value of @code{silent_functions}. -@end defvr - -@defvr {Built-in Variable} warn_missing_semicolon -If the value of this variable is nonzero, Octave will warn when -statements in function definitions don't end in semicolons. The default -value is 0. -@end defvr +@DOCSTRING(warn_missing_semicolon) @node Multiple Return Values, Variable-length Argument Lists, Defining Functions, Functions and Scripts @section Multiple Return Values @@ -366,27 +345,11 @@ At the top level, @code{nargout} is undefined. @end defvr -@defvr {Built-in Variable} default_return_value -The value given to otherwise uninitialized return values if -@code{define_all_return_values} is nonzero. The default value is -@code{[]}. -@end defvr +@DOCSTRING(default_return_value) -@defvr {Built-in Variable} define_all_return_values -If the value of @code{define_all_return_values} is nonzero, Octave -will substitute the value specified by @code{default_return_value} for -any return values that remain undefined when a function returns. The -default value is 0. -@end defvr +@DOCSTRING(define_all_return_values) -@deftypefn {Function File} {} nargchk (@var{nargin_min}, @var{nargin_max}, @var{n}) -If @var{n} is in the range @var{nargin_min} through @var{nargin_max} -inclusive, return the empty matrix. Otherwise, return a message -indicating whether @var{n} is too large or too small. - -This is useful for checking to see that the number of arguments supplied -to a function is within an acceptable range. -@end deftypefn +@DOCSTRING(nargchk) @node Variable-length Argument Lists, Variable-length Return Lists, Multiple Return Values, Functions and Scripts @section Variable-length Argument Lists @@ -418,20 +381,9 @@ The ellipsis that marks the variable argument list may only appear once and must be the last element in the list of arguments. -@deftypefn {Built-in Function} {} va_start () -Position an internal pointer to the first unnamed argument and allows -you to cycle through the arguments more than once. It is not necessary -to call @code{va_start} if you do not plan to cycle through the -arguments more than once. This function may only be called inside -functions that have been declared to accept a variable number of input -arguments. -@end deftypefn +@DOCSTRING(va_arg) -@deftypefn {Built-in Function} {} va_arg () -Return the value of the next available argument and move the internal -pointer to the next argument. It is an error to call @code{va_arg()} -when there are no more arguments available. -@end deftypefn +@DOCSTRING(va_start) Sometimes it is useful to be able to pass all unnamed arguments to another function. The keyword @var{all_va_args} makes this very easy to @@ -497,15 +449,7 @@ return list may only appear once and must be the last element in the list of returned values. -@deftypefn {Built-in Function} {} vr_val (@var{val}) -Each time this function is called, it places the value of its argument -at the end of the list of values to return from the current function. -Once @code{vr_val} has been called, there is no way to go back to the -beginning of the list and rewrite any of the return values. This -function may only be called within functions that have been declared to -return an unspecified number of output arguments (by using the special -ellipsis notation described above). -@end deftypefn +@DOCSTRING(vr_val) @node Returning From a Function, Function Files, Variable-length Return Lists, Functions and Scripts @section Returning From a Function @@ -555,25 +499,7 @@ at the end of every function definition. @end defvr -@defvr {Built-in Variable} return_last_computed_value -If the value of @code{return_last_computed_value} is true, and a -function is defined without explicitly specifying a return value, the -function will return the value of the last expression. Otherwise, no -value will be returned. The default value is 0. - -For example, the function - -@example -function f () - 2 + 2; -endfunction -@end example - -@noindent -will either return nothing, if the value of -@code{return_last_computed_value} is 0, or 4, if the value of -@code{return_last_computed_value} is nonzero. -@end defvr +@DOCSTRING(return_last_computed_value) @node Function Files, Script Files, Returning From a Function, Functions and Scripts @section Function Files @@ -630,62 +556,13 @@ @c XXX FIXME XXX -- note about time stamps on files in NFS environments? -@defvr {Built-in Variable} DEFAULT_LOADPATH -A colon separated list of directories in which to search for function -files by default. The value of this variable is also automatically -substituted for leading, trailing, or doubled colons that appear in the -built-in variable @code{LOADPATH}. -@end defvr - -@defvr {Built-in Variable} LOADPATH -A colon separated list of directories in which to search for function -files. @xref{Functions and Scripts}. The value of @code{LOADPATH} -overrides the environment variable @code{OCTAVE_PATH}. @xref{Installation}. +@DOCSTRING(DEFAULT_LOADPATH) -@code{LOADPATH} is now handled in the same way as @TeX{} handles -@code{TEXINPUTS}. Leading, trailing, or doubled colons that appear in -@code{LOADPATH} are replaced by the value of @code{DEFAULT_LOADPATH}. -The default value of @code{LOADPATH} is @code{":"}, which tells Octave -to search in the directories specified by @code{DEFAULT_LOADPATH}. - -In addition, if any path element ends in @samp{//}, that directory and -all subdirectories it contains are searched recursively for function -files. This can result in a slight delay as Octave caches the lists of -files found in the @code{LOADPATH} the first time Octave searches for a -function. After that, searching is usually much faster because Octave -normally only needs to search its internal cache for files. +@DOCSTRING(LOADPATH) -To improve performance of recursive directory searching, it is best for -each directory that is to be searched recursively to contain -@emph{either} additional subdirectories @emph{or} function files, but -not a mixture of both. - -@xref{Organization of Functions} for a description of the function file -directories that are distributed with Octave. -@end defvr +@DOCSTRING(ignore_function_time_stamp) -@defvr {Built-in Variable} ignore_function_time_stamp -This variable can be used to prevent Octave from making the system call -@code{stat} each time it looks up functions defined in function files. -If @code{ignore_function_time_stamp} to @code{"system"}, Octave will not -automatically recompile function files in subdirectories of -@file{@var{octave-home}/lib/@var{version}} if they have changed since -they were last compiled, but will recompile other function files in the -@code{LOADPATH} if they change. If set to @code{"all"}, Octave will not -recompile any function files unless their definitions are removed with -@code{clear}. For any other value of @code{ignore_function_time_stamp}, -Octave will always check to see if functions defined in function files -need to recompiled. The default value of @code{ignore_function_time_stamp} is -@code{"system"}. -@end defvr - -@defvr {Built-in Variable} warn_function_name_clash -If the value of @code{warn_function_name_clash} is nonzero, a warning is -issued when Octave finds that the name of a function defined in a -function file differs from the name of the file. (If the names -disagree, the name declared inside the file is ignored.) If the value -is 0, the warning is omitted. The default value is 1. -@end defvr +@DOCSTRING(warn_function_name_clash) @node Script Files, Dynamically Linked Functions, Function Files, Functions and Scripts @section Script Files @@ -788,11 +665,7 @@ the name @file{@var{file}.m}, you can use the function @code{source} to execute commands from any file. -@deftypefn {Built-in Function} {} source (@var{file}) -Parse and execute the contents of @var{file}. This is equivalent to -executing commands from a script file, but without requiring the file to -be named @file{@var{file}.m}. -@end deftypefn +@DOCSTRING(source) @node Dynamically Linked Functions, Organization of Functions, Script Files, Functions and Scripts @section Dynamically Linked Functions @@ -969,18 +842,15 @@ control how Octave behaves when dynamically linked functions are cleared or reloaded. +@c XXX FIXME XXX -- this variable no longer exists! + @defvr {Built-in Variable} auto_unload_dot_oct_files If the value of @code{auto_unload_dot_oct_files} is nonzero, Octave will automatically unload any @file{.oct} files when there are no longer any functions in the symbol table that reference them. @end defvr -@defvr {Built-in Variable} warn_reload_forces_clear -If several functions have been loaded from the same file, Octave must -clear all the functions before any one of them can be reloaded. If -@code{warn_reload_forces_clear}, Octave will warn you when this happens, -and print a list of the additional functions that it is forced to clear. -@end defvr +@DOCSTRING(warn_reload_forces_clear) Additional examples for writing dynamically linked functions are available in the files in the @file{src} directory of the Octave diff --git a/doc/interpreter/matrix.txi b/doc/interpreter/matrix.txi --- a/doc/interpreter/matrix.txi +++ b/doc/interpreter/matrix.txi @@ -167,11 +167,10 @@ @c XXX FIXME XXX -- is this really worth documenting? @c -@c @DOCSTRING(ok_to_lose_imaginary_part) +@c DOCSTRING(ok_to_lose_imaginary_part) @c @c XXX FIXME XXX -- this is here because it is used by @code{ones}, @c @code{zeros}, @code{rand}, etc. -@c @end defvr The functions @code{linspace} and @code{logspace} make it very easy to create vectors with evenly or logarithmically spaced elements. diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -18,6 +18,7 @@ * general/tril.m: Ditto. * general/triu.m: Ditto. * general/logspace.m: Ditto. + * general/nargchk.m: Ditto. 1999-11-20 John W. Eaton diff --git a/scripts/general/nargchk.m b/scripts/general/nargchk.m --- a/scripts/general/nargchk.m +++ b/scripts/general/nargchk.m @@ -17,11 +17,15 @@ ## Software Foundation, 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -## usage: nargchk (nargin_min, nargin_max, n) -## -## If N is in the range NARGIN_MIN to NARGIN_MAX, return the empty -## matrix. Otherwise, return a message indicating whether N is too -## large or too small. +## -*- texinfo -*- +## @deftypefn {Function File} {} nargchk (@var{nargin_min}, @var{nargin_max}, @var{n}) +## If @var{n} is in the range @var{nargin_min} through @var{nargin_max} +## inclusive, return the empty matrix. Otherwise, return a message +## indicating whether @var{n} is too large or too small. +## +## This is useful for checking to see that the number of arguments supplied +## to a function is within an acceptable range. +## @end deftypefn ## Author: jwe diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -6,7 +6,17 @@ * DLD-FUNCTIONS/sort.cc (Fsort): Ditto. * mappers.cc (Fisinf, Fisnan, Ffinite): Ditto. * data.cc (Fall, Fany, Fdiag, Fones, Fzeros, Feye, Flinspace): Ditto. - * ov.cc (Vok_to_lose_imaginary_part): Ditto. + * defaults.cc (Vloadpath, Vdefault_loadpath): Ditto. + * parse.y (Feval, Ffeval, Vdefault_eval_print_flag, + Vwarn_missing_semicolon, Vwarn_function_name_clash, Fsource): Ditto. + * ov-usr-fcn.cc (Vmax_recursion_depth, Vdefault_return_value, + Vdefine_all_return_values, Vreturn_last_computed_value): Ditto. + * ov.cc (Vok_to_lose_imaginary_part, Vdo_fortran_indexing, + Vprefer_column_vectors, Vresize_on_range_error, + Vwarn_divide_by_zero): Ditto. + * pt-stmt.cc (Vsilent_functions): Ditto. + * variables.cc (Vignore_function_time_stamp): Ditto. + * dynamic-ld.cc (Vwarn_reload_forces_clear): Ditto. 1999-11-20 John W. Eaton diff --git a/src/defaults.cc b/src/defaults.cc --- a/src/defaults.cc +++ b/src/defaults.cc @@ -451,13 +451,42 @@ @end defvr"); DEFVAR (LOADPATH, Vload_path, loadpath, - "colon separated list of directories to search for scripts.\n\ -The default value is \":\", which means to search the default list\n\ -of directories. The default list of directories may be found in\n\ -the built-in constant DEFAULT_LOADPATH"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} LOADPATH\n\ +A colon separated list of directories in which to search for function\n\ +files. @xref{Functions and Scripts}. The value of @code{LOADPATH}\n\ +overrides the environment variable @code{OCTAVE_PATH}. @xref{Installation}.\n\ +\n\ +@code{LOADPATH} is now handled in the same way as @TeX{} handles\n\ +@code{TEXINPUTS}. Leading, trailing, or doubled colons that appear in\n\ +@code{LOADPATH} are replaced by the value of @code{DEFAULT_LOADPATH}.\n\ +The default value of @code{LOADPATH} is @code{\":\"}, which tells Octave\n\ +to search in the directories specified by @code{DEFAULT_LOADPATH}.\n\ +\n\ +In addition, if any path element ends in @samp{//}, that directory and\n\ +all subdirectories it contains are searched recursively for function\n\ +files. This can result in a slight delay as Octave caches the lists of\n\ +files found in the @code{LOADPATH} the first time Octave searches for a\n\ +function. After that, searching is usually much faster because Octave\n\ +normally only needs to search its internal cache for files.\n\ +\n\ +To improve performance of recursive directory searching, it is best for\n\ +each directory that is to be searched recursively to contain\n\ +@emph{either} additional subdirectories @emph{or} function files, but\n\ +not a mixture of both.\n\ +\n\ +@xref{Organization of Functions} for a description of the function file\n\ +directories that are distributed with Octave.\n\ +@end defvr"); DEFCONST (DEFAULT_LOADPATH, Vdefault_load_path, - "the default colon separated list of directories to search for scripts"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} DEFAULT_LOADPATH\n\ +A colon separated list of directories in which to search for function\n\ +files by default. The value of this variable is also automatically\n\ +substituted for leading, trailing, or doubled colons that appear in the\n\ +built-in variable @code{LOADPATH}.\n\ +@end defvr"); DEFVAR (IMAGEPATH, OCTAVE_IMAGEPATH, imagepath, "colon separated list of directories to search for image files"); diff --git a/src/dynamic-ld.cc b/src/dynamic-ld.cc --- a/src/dynamic-ld.cc +++ b/src/dynamic-ld.cc @@ -333,7 +333,14 @@ symbols_of_dynamic_ld (void) { DEFVAR (warn_reload_forces_clear, 1.0, warn_reload_forces_clear, - "warn if reloading a .oct file forces other functions to be cleared"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} warn_reload_forces_clear\n\ +If several functions have been loaded from the same file, Octave must\n\ +clear all the functions before any one of them can be reloaded. If\n\ +@code{warn_reload_forces_clear}, Octave will warn you when this happens,\n\ +and print a list of the additional functions that it is forced to clear.\n\ +@end defvr"); + } /* diff --git a/src/ov-usr-fcn.cc b/src/ov-usr-fcn.cc --- a/src/ov-usr-fcn.cc +++ b/src/ov-usr-fcn.cc @@ -594,22 +594,54 @@ symbols_of_ov_usr_fcn (void) { DEFVAR (default_return_value, Matrix (), 0, - "the default for value for unitialized variables returned from\n\ -functions. Only used if the variable initialize_return_values is\n\ -nonzero."); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} default_return_value\n\ +The value given to otherwise uninitialized return values if\n\ +@code{define_all_return_values} is nonzero. The default value is\n\ +@code{[]}.\n\ +@end defvr"); DEFVAR (define_all_return_values, 0.0, define_all_return_values, - "control whether values returned from functions should have a\n\ -value even if one has not been explicitly assigned. See also\n\ -default_return_value"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} define_all_return_values\n\ +If the value of @code{define_all_return_values} is nonzero, Octave\n\ +will substitute the value specified by @code{default_return_value} for\n\ +any return values that remain undefined when a function returns. The\n\ +default value is 0.\n\ +@end defvr"); DEFVAR (max_recursion_depth, 256.0, max_recursion_depth, - "maximum nesting level for functions called recursively.\n\ -The default value is 256."); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} max_recursion_depth\n\ +Limit the number of times a function may be called recursively.\n\ +If the limit is exceeded, an error message is printed and control\n\ +returns to the top level.\n\ +\n\ +The default value is 256.\n\ +@end defvr"); DEFVAR (return_last_computed_value, 0.0, return_last_computed_value, - "if a function does not return any values explicitly, return the\n\ - last computed value"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} return_last_computed_value\n\ +If the value of @code{return_last_computed_value} is true, and a\n\ +function is defined without explicitly specifying a return value, the\n\ +function will return the value of the last expression. Otherwise, no\n\ +value will be returned. The default value is 0.\n\ +\n\ +For example, the function\n\ +\n\ +@example\n\ +function f ()\n\ + 2 + 2;\n\ +endfunction\n\ +@end example\n\ +\n\ +@noindent\n\ +will either return nothing, if the value of\n\ +@code{return_last_computed_value} is 0, or 4, if the value of\n\ +@code{return_last_computed_value} is nonzero.\n\ +@end defvr"); + } /* diff --git a/src/ov.cc b/src/ov.cc --- a/src/ov.cc +++ b/src/ov.cc @@ -1518,7 +1518,13 @@ symbols_of_ov (void) { DEFVAR (do_fortran_indexing, 0.0, do_fortran_indexing, - "allow single indices for matrices"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} do_fortran_indexing\n\ +If the value of @code{do_fortran_indexing} is nonzero, Octave allows \n\ +you to select elements of a two-dimensional matrix using a single index\n\ +by treating the matrix as a single vector created from the columns of\n\ +the matrix. The default value is 0. \n\ +@end defvr"); DEFVAR (implicit_str_to_num_ok, 0.0, implicit_str_to_num_ok, "-*- texinfo -*-\n\ @@ -1541,7 +1547,24 @@ @end defvr"); DEFVAR (prefer_column_vectors, 1.0, prefer_column_vectors, - "prefer column/row vectors"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} prefer_column_vectors\n\ +If @code{prefer_column_vectors} is nonzero, operations like\n\ +\n\ +@example\n\ +for i = 1:10\n\ + a (i) = i;\n\ +endfor\n\ +@end example\n\ +\n\ +@noindent\n\ +(for @code{a} previously undefined) produce column vectors. Otherwise, row\n\ +vectors are preferred. The default value is 1.\n\ +\n\ +If a variable is already defined to be a vector (a matrix with a single\n\ +row or column), the original orientation is respected, regardless of the\n\ +value of @code{prefer_column_vectors}.\n\ +@end defvr"); DEFVAR (print_answer_id_name, 1.0, print_answer_id_name, "set output style to print `var_name = ...'"); @@ -1555,7 +1578,24 @@ @end defvr"); DEFVAR (resize_on_range_error, 1.0, resize_on_range_error, - "enlarge matrices on assignment"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} resize_on_range_error\n\ +If the value of @code{resize_on_range_error} is nonzero, expressions\n\ +like\n\ +\n\ +@example\n\ +for i = 1:10\n\ + a (i) = sqrt (i);\n\ +endfor\n\ +@end example\n\ +\n\ +@noindent\n\ +(for @code{a} previously undefined) result in the variable @code{a}\n\ +being resized to be just large enough to hold the new value. New\n\ +elements that have not been given a value are set to zero. If the value\n\ +of @code{resize_on_range_error} is 0, an error message is printed and\n\ +control is returned to the top level. The default value is 1.\n\ +@end defvr"); DEFVAR (struct_levels_to_print, 2.0, struct_levels_to_print, "-*- texinfo -*-\n\ @@ -1565,7 +1605,13 @@ @end defvr"); DEFVAR (warn_divide_by_zero, 1.0, warn_divide_by_zero, - "if TRUE, warn about division by zero"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} warn_divide_by_zero\n\ +If the value of @code{warn_divide_by_zero} is nonzero, a warning\n\ +is issued when Octave encounters a division by zero. If the value is\n\ +0, the warning is omitted. The default value is 1.\n\ +@end defvr"); + } /* diff --git a/src/parse.y b/src/parse.y --- a/src/parse.y +++ b/src/parse.y @@ -3072,10 +3072,12 @@ } DEFUN (source, args, , - "source (FILE)\n\ -\n\ -Parse and execute the contents of FILE. Like executing commands in a\n\ -script file but without requiring the file to be named `FILE.m'.") + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} source (@var{file})\n\ +Parse and execute the contents of @var{file}. This is equivalent to\n\ +executing commands from a script file, but without requiring the file to\n\ +be named @file{@var{file}.m}.\n\ +@end deftypefn") { octave_value_list retval; @@ -3156,9 +3158,26 @@ } DEFUN (feval, args, nargout, - "feval (NAME, ARGS, ...)\n\ + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} feval (@var{name}, @dots{})\n\ +Evaluate the function named @var{name}. Any arguments after the first\n\ +are passed on to the named function. For example,\n\ +\n\ +@example\n\ +feval (\"acos\", -1)\n\ + @result{} 3.1416\n\ +@end example\n\ \n\ -evaluate NAME as a function, passing ARGS as its arguments") +@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\ +@end deftypefn") { octave_value_list retval; @@ -3248,10 +3267,37 @@ } DEFUN (eval, args, nargout, - "eval (TRY, CATCH)\n\ + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} eval (@var{try}, @var{catch})\n\ +Parse the string @var{try} and evaluate it as if it were an Octave\n\ +program, returning the last value computed. If that fails, evaluate\n\ +the string @var{catch}. The string @var{try} is evaluated in the\n\ +current context, so any results remain available after @code{eval}\n\ +returns. For example,\n\ +\n\ +@example\n\ +@group\n\ +eval (\"a = 13\")\n\ + @print{} a = 13\n\ + @result{} 13\n\ +@end group\n\ +@end example\n\ \n\ -Evaluate the string TRY as octave code. If that fails, evaluate the\n\ -string CATCH.") +In this case, the value of the evaluated expression is printed and it is\n\ +also returned returned from @code{eval}. Just as with any other\n\ +expression, you can turn printing off by ending the expression in a\n\ +semicolon. For example,\n\ +\n\ +@example\n\ +eval (\"a = 13;\")\n\ + @result{} 13\n\ +@end example\n\ +\n\ +In this example, the variable @code{a} has been given the value 13, but\n\ +the value of the expression is not printed. You can also turn off\n\ +automatic printing for all expressions executed by @code{eval} using the\n\ +variable @code{default_eval_print_flag}.\n\ +@end deftypefn") { octave_value_list retval; @@ -3350,8 +3396,12 @@ symbols_of_parse (void) { DEFVAR (default_eval_print_flag, 1.0, default_eval_print_flag, - "If the value of this variable is nonzero, Octave will print the\n\ -results of commands executed by eval() that do not end with semicolons."); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} default_eval_print_flag\n\ +If the value of this variable is nonzero, Octave prints the results of\n\ +commands executed by @code{eval} that do not end with semicolons. If it\n\ +is zero, automatic printing is suppressed. The default value is 1.\n\ +@end defvr"); DEFVAR (warn_assign_as_truth_value, 1.0, warn_assign_as_truth_value, "-*- texinfo -*-\n\ @@ -3418,14 +3468,25 @@ @end defvr"); DEFVAR (warn_function_name_clash, 1.0, warn_function_name_clash, - "produce warning if function name conflicts with file name"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} warn_function_name_clash\n\ +If the value of @code{warn_function_name_clash} is nonzero, a warning is\n\ +issued when Octave finds that the name of a function defined in a\n\ +function file differs from the name of the file. (If the names\n\ +disagree, the name declared inside the file is ignored.) If the value\n\ +is 0, the warning is omitted. The default value is 1.\n\ +@end defvr"); DEFVAR (warn_future_time_stamp, 1.0, warn_future_time_stamp, "warn if a function file has a time stamp that is in the future"); DEFVAR (warn_missing_semicolon, 0.0, warn_missing_semicolon, - "produce a warning if a statement in a function file is not\n\ -terminated with a semicolon"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} warn_missing_semicolon\n\ +If the value of this variable is nonzero, Octave will warn when\n\ +statements in function definitions don't end in semicolons. The default\n\ +value is 0.\n\ +@end defvr"); DEFVAR (warn_variable_switch_label, 0.0, warn_variable_switch_label, "-*- texinfo -*-\n\ diff --git a/src/pt-stmt.cc b/src/pt-stmt.cc --- a/src/pt-stmt.cc +++ b/src/pt-stmt.cc @@ -190,7 +190,26 @@ symbols_of_pt_stmt (void) { DEFVAR (silent_functions, 0.0, silent_functions, - "suppress printing results in called functions"); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} silent_functions\n\ +If the value of @code{silent_functions} is nonzero, internal output\n\ +from a function is suppressed. Otherwise, the results of expressions\n\ +within a function body that are not terminated with a semicolon will\n\ +have their values printed. The default value is 0.\n\ +\n\ +For example, if the function\n\ +\n\ +@example\n\ +function f ()\n\ + 2 + 2\n\ +endfunction\n\ +@end example\n\ +\n\ +@noindent\n\ +is executed, Octave will either print @samp{ans = 4} or nothing\n\ +depending on the value of @code{silent_functions}.\n\ +@end defvr"); + } /* diff --git a/src/variables.cc b/src/variables.cc --- a/src/variables.cc +++ b/src/variables.cc @@ -1311,8 +1311,22 @@ ""); DEFVAR (ignore_function_time_stamp, "system", ignore_function_time_stamp, - "don't check to see if function files have changed since they were\n\ -last compiled. Possible values are \"system\" and \"all\""); + "-*- texinfo -*-\n\ +@defvr {Built-in Variable} ignore_function_time_stamp\n\ +This variable can be used to prevent Octave from making the system call\n\ +@code{stat} each time it looks up functions defined in function files.\n\ +If @code{ignore_function_time_stamp} to @code{\"system\"}, Octave will not\n\ +automatically recompile function files in subdirectories of\n\ +@file{@var{octave-home}/lib/@var{version}} if they have changed since\n\ +they were last compiled, but will recompile other function files in the\n\ +@code{LOADPATH} if they change. If set to @code{\"all\"}, Octave will not\n\ +recompile any function files unless their definitions are removed with\n\ +@code{clear}. For any other value of @code{ignore_function_time_stamp},\n\ +Octave will always check to see if functions defined in function files\n\ +need to recompiled. The default value of @code{ignore_function_time_stamp} is\n\ +@code{\"system\"}.\n\ +@end defvr"); + } /*