Mercurial > hg > octave-lyh
changeset 6635:c9c504d939c5
[project @ 2007-05-19 10:36:56 by dbateman]
author | dbateman |
---|---|
date | Sat, 19 May 2007 10:36:57 +0000 |
parents | 8c2fff7b50b0 |
children | de8a8ba43848 |
files | doc/ChangeLog doc/interpreter/func.txi src/ChangeLog src/ov-fcn-inline.cc |
diffstat | 4 files changed, 79 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,6 +1,11 @@ +2007-05-19 David Bateman <dbatemna@free.fr> + + * interpreter/func.txi: Additional documentation for function + locking, dispatch and autoloading. + 2007-05-16 Søren Hauberg <hauberg@gmail.com> - * interpreter/expr.txi: Imrove docs. + * interpreter/expr.txi: Improve docs. 2007-05-14 John W. Eaton <jwe@octave.org>
--- a/doc/interpreter/func.txi +++ b/doc/interpreter/func.txi @@ -599,12 +599,6 @@ @DOCSTRING(mfilename) -@DOCSTRING(mlock) - -@DOCSTRING(munlock) - -@DOCSTRING(mislocked) - @DOCSTRING(addpath) @DOCSTRING(genpath) @@ -625,14 +619,11 @@ @DOCSTRING(ignore_function_time_stamp) -@DOCSTRING(autoload) - -@DOCSTRING(builtin) - -@DOCSTRING(dispatch) @menu * Subfunctions:: +* Overloading and Autoloading:: +* Function Locking:: @end menu @node Subfunctions @@ -664,6 +655,72 @@ function @code{f} or from the other subfunctions, but not from outside the file @file{f.m}. +@node Overloading and Autoloading +@subsection Overloading and Autoloading + +The @code{dispatch} function can be used to alias one function name to +another. It can be used to alias all calls to a particular function name +to another function, or the alias can be limited to only a particular +variable type. Consider the example + +@example +@group +function y = spsin (x) + printf ("Calling spsin\n"); + fflush(stdout); + y = spfun ("sin", x); +endfunction + +dispatch ("sin", "spsin", "sparse matrix"); +y0 = sin(eye(3)); +y1 = sin(speye(3)); +@end group +@end example + +@noindent +Which aliases the @code{spsin} to @code{sin}, but only for real sparse +matrices. Note that the builtin @code{sin} already correctly treats +sparse matrices and so this example is only illustrative. + +@DOCSTRING(dispatch) + +@DOCSTRING(builtin) + +A single dynamically linked file might define several +functions. However, as Octave searches for functions based on the +functions filename, Octave needs a manner in which to find each of the +functions in the dynamically linked file. On operating systems that +support symbolic links, it is possible to create a symbolic link to the +original file for each of the functions which it contains. + +However, there is at least one well known operating system that doesn't +support symbolic links. Making copies of the original file for each of +the functions is also possible, but is undesirable as it multiples the +amount of disk space used by Octave. Instead Octave supplies the +@code{autoload} function, that permits the user to define in which +file a certain function will be found. + +@DOCSTRING(autoload) + +@node Function Locking +@subsection Function Locking + +It is sometime desirable to lock a function into memory with the +@code{mlock} function. This is typically used for dynamically linked +functions in Oct-files or mex-files, that contain some initialization, +and it is desireable that a @code{clear} does not remove this +initialization. + +This might equally be used to prevent changes to a function from having +effect in Octave, though a similar effect can be had with the +@code{ignore_function_time_stamp} function. + +@DOCSTRING(mlock) + +@DOCSTRING(munlock) + +@DOCSTRING(mislocked) + @node Script Files @section Script Files
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2007-05-19 David Bateman <dbatemna@free.fr> + + * ov-fcn-inline.cc (Fvectorize): Doc fix. + 2007-05-16 Søren Hauberg <soren@hauberg.org> * ov.cc (Fsubsref, Fsubsasgn): Doc fix.
--- a/src/ov-fcn-inline.cc +++ b/src/ov-fcn-inline.cc @@ -809,7 +809,7 @@ DEFUN (vectorize, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} argnames (@var{fun})\n\ +@deftypefn {Built-in Function} {} vectorize (@var{fun})\n\ Create a vectorized version of the inline function @var{fun}\n\ by replacing all occurrences of @code{*}, @code{/}, etc., with\n\ @code{.*}, @code{./}, etc.\n\