Mercurial > octave-antonio
diff doc/interpreter/func.txi @ 6635:c9c504d939c5
[project @ 2007-05-19 10:36:56 by dbateman]
author | dbateman |
---|---|
date | Sat, 19 May 2007 10:36:57 +0000 |
parents | 49f0820425a8 |
children | 15837c5982cb |
line wrap: on
line diff
--- a/doc/interpreter/func.txi Fri May 18 21:38:13 2007 +0000 +++ b/doc/interpreter/func.txi Sat May 19 10:36:57 2007 +0000 @@ -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