Mercurial > octave-libgccjit
comparison libinterp/parse-tree/oct-parse.in.yy @ 16789:2f63d2f3ff11
doc: Update docstrings in oct-parse.in.yy.
* libinterp/parse-tree/oct-parse.in.yy(autoload, source, feval, builtin, eval):
Improve wording of docstrings. Add examples.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 20 Jun 2013 17:48:12 -0700 |
parents | d3619d4d267c |
children | 77c8aae15908 |
comparison
equal
deleted
inserted
replaced
16788:f89de736eecd | 16789:2f63d2f3ff11 |
---|---|
3521 a file name in the same directory as the function or script from which\n\ | 3521 a file name in the same directory as the function or script from which\n\ |
3522 the autoload command was run. @var{file} should not depend on the\n\ | 3522 the autoload command was run. @var{file} should not depend on the\n\ |
3523 Octave load path.\n\ | 3523 Octave load path.\n\ |
3524 \n\ | 3524 \n\ |
3525 Normally, calls to @code{autoload} appear in PKG_ADD script files that\n\ | 3525 Normally, calls to @code{autoload} appear in PKG_ADD script files that\n\ |
3526 are evaluated when a directory is added to the Octave's load path. To\n\ | 3526 are evaluated when a directory is added to Octave's load path. To\n\ |
3527 avoid having to hardcode directory names in @var{file}, if @var{file}\n\ | 3527 avoid having to hardcode directory names in @var{file}, if @var{file}\n\ |
3528 is in the same directory as the PKG_ADD script then\n\ | 3528 is in the same directory as the PKG_ADD script then\n\ |
3529 \n\ | 3529 \n\ |
3530 @example\n\ | 3530 @example\n\ |
3531 autoload (\"foo\", \"bar.oct\");\n\ | 3531 autoload (\"foo\", \"bar.oct\");\n\ |
3532 @end example\n\ | 3532 @end example\n\ |
3533 \n\ | 3533 \n\ |
3534 @noindent\n\ | 3534 @noindent\n\ |
3535 will load the function @code{foo} from the file @code{bar.oct}. The above\n\ | 3535 will load the function @code{foo} from the file @code{bar.oct}. The above\n\ |
3536 when @code{bar.oct} is not in the same directory or uses like\n\ | 3536 usage when @code{bar.oct} is not in the same directory or usages such as\n\ |
3537 \n\ | 3537 \n\ |
3538 @example\n\ | 3538 @example\n\ |
3539 autoload (\"foo\", file_in_loadpath (\"bar.oct\"))\n\ | 3539 autoload (\"foo\", file_in_loadpath (\"bar.oct\"))\n\ |
3540 @end example\n\ | 3540 @end example\n\ |
3541 \n\ | 3541 \n\ |
3542 @noindent\n\ | 3542 @noindent\n\ |
3543 are strongly discouraged, as their behavior might be unpredictable.\n\ | 3543 are strongly discouraged, as their behavior may be unpredictable.\n\ |
3544 \n\ | 3544 \n\ |
3545 With no arguments, return a structure containing the current autoload map.\n\ | 3545 With no arguments, return a structure containing the current autoload map.\n\ |
3546 @seealso{PKG_ADD}\n\ | 3546 @seealso{PKG_ADD}\n\ |
3547 @end deftypefn") | 3547 @end deftypefn") |
3548 { | 3548 { |
3788 } | 3788 } |
3789 | 3789 |
3790 return retval; | 3790 return retval; |
3791 } | 3791 } |
3792 | 3792 |
3793 | |
3794 DEFUN (source, args, , | 3793 DEFUN (source, args, , |
3795 "-*- texinfo -*-\n\ | 3794 "-*- texinfo -*-\n\ |
3796 @deftypefn {Built-in Function} {} source (@var{file})\n\ | 3795 @deftypefn {Built-in Function} {} source (@var{file})\n\ |
3797 Parse and execute the contents of @var{file}. This is equivalent to\n\ | 3796 Parse and execute the contents of @var{file}. This is equivalent to\n\ |
3798 executing commands from a script file, but without requiring the file to\n\ | 3797 executing commands from a script file, but without requiring the file to\n\ |
3915 | 3914 |
3916 DEFUN (feval, args, nargout, | 3915 DEFUN (feval, args, nargout, |
3917 "-*- texinfo -*-\n\ | 3916 "-*- texinfo -*-\n\ |
3918 @deftypefn {Built-in Function} {} feval (@var{name}, @dots{})\n\ | 3917 @deftypefn {Built-in Function} {} feval (@var{name}, @dots{})\n\ |
3919 Evaluate the function named @var{name}. Any arguments after the first\n\ | 3918 Evaluate the function named @var{name}. Any arguments after the first\n\ |
3920 are passed on to the named function. For example,\n\ | 3919 are passed as inputs to the named function. For example,\n\ |
3921 \n\ | 3920 \n\ |
3922 @example\n\ | 3921 @example\n\ |
3923 @group\n\ | 3922 @group\n\ |
3924 feval (\"acos\", -1)\n\ | 3923 feval (\"acos\", -1)\n\ |
3925 @result{} 3.1416\n\ | 3924 @result{} 3.1416\n\ |
3945 @end group\n\ | 3944 @end group\n\ |
3946 @end example\n\ | 3945 @end example\n\ |
3947 \n\ | 3946 \n\ |
3948 @noindent\n\ | 3947 @noindent\n\ |
3949 are equivalent ways to call the function referred to by @var{f}. If it\n\ | 3948 are equivalent ways to call the function referred to by @var{f}. If it\n\ |
3950 cannot be predicted beforehand that @var{f} is a function handle or the\n\ | 3949 cannot be predicted beforehand whether @var{f} is a function handle,\n\ |
3951 function name in a string, @code{feval} can be used instead.\n\ | 3950 function name in a string, or inline function then @code{feval} can be used\n\ |
3951 instead.\n\ | |
3952 @end deftypefn") | 3952 @end deftypefn") |
3953 { | 3953 { |
3954 octave_value_list retval; | 3954 octave_value_list retval; |
3955 | 3955 |
3956 int nargin = args.length (); | 3956 int nargin = args.length (); |
3963 return retval; | 3963 return retval; |
3964 } | 3964 } |
3965 | 3965 |
3966 DEFUN (builtin, args, nargout, | 3966 DEFUN (builtin, args, nargout, |
3967 "-*- texinfo -*-\n\ | 3967 "-*- texinfo -*-\n\ |
3968 @deftypefn {Loadable Function} {[@dots{}]} builtin (@var{f}, @dots{})\n\ | 3968 @deftypefn {Loadable Function} {[@dots{}] =} builtin (@var{f}, @dots{})\n\ |
3969 Call the base function @var{f} even if @var{f} is overloaded to\n\ | 3969 Call the base function @var{f} even if @var{f} is overloaded to\n\ |
3970 another function for the given type signature.\n\ | 3970 another function for the given type signature.\n\ |
3971 \n\ | |
3972 This is normally useful when doing object-oriented programming and there\n\ | |
3973 is a requirement to call one of Octave's base functions rather than\n\ | |
3974 the overloaded one of a new class.\n\ | |
3975 \n\ | |
3976 A trivial example which redefines the @code{sin} function to be the\n\ | |
3977 @code{cos} function shows how @code{builtin} works.\n\ | |
3978 \n\ | |
3979 @example\n\ | |
3980 @group\n\ | |
3981 sin (0)\n\ | |
3982 @result{} 0\n\ | |
3983 function y = sin (x), y = cos (x); endfunction\n\ | |
3984 sin (0)\n\ | |
3985 @result{} 1\n\ | |
3986 builtin (\"sin\", 0)\n\ | |
3987 @result{} 0\n\ | |
3988 @end group\n\ | |
3989 @end example\n\ | |
3971 @end deftypefn") | 3990 @end deftypefn") |
3972 { | 3991 { |
3973 octave_value_list retval; | 3992 octave_value_list retval; |
3974 | 3993 |
3975 int nargin = args.length (); | 3994 int nargin = args.length (); |
4119 Parse the string @var{try} and evaluate it as if it were an Octave\n\ | 4138 Parse the string @var{try} and evaluate it as if it were an Octave\n\ |
4120 program. If that fails, evaluate the optional string @var{catch}.\n\ | 4139 program. If that fails, evaluate the optional string @var{catch}.\n\ |
4121 The string @var{try} is evaluated in the current context,\n\ | 4140 The string @var{try} is evaluated in the current context,\n\ |
4122 so any results remain available after @code{eval} returns.\n\ | 4141 so any results remain available after @code{eval} returns.\n\ |
4123 \n\ | 4142 \n\ |
4124 The following example makes the variable @var{a} with the approximate\n\ | 4143 The following example makes the variable @var{A} with the approximate\n\ |
4125 value 3.1416 available.\n\ | 4144 value 3.1416 available.\n\ |
4126 \n\ | 4145 \n\ |
4127 @example\n\ | 4146 @example\n\ |
4128 eval (\"a = acos(-1);\");\n\ | 4147 eval (\"A = acos(-1);\");\n\ |
4129 @end example\n\ | 4148 @end example\n\ |
4130 \n\ | 4149 \n\ |
4131 If an error occurs during the evaluation of @var{try} the @var{catch}\n\ | 4150 If an error occurs during the evaluation of @var{try} the @var{catch}\n\ |
4132 string is evaluated, as the following example shows:\n\ | 4151 string is evaluated, as the following example shows:\n\ |
4133 \n\ | 4152 \n\ |