1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<html lang="en">
<head>
<title>Private Functions - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.11">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Function-Files.html#Function-Files" title="Function Files">
<link rel="prev" href="Subfunctions.html#Subfunctions" title="Subfunctions">
<link rel="next" href="Overloading-and-Autoloading.html#Overloading-and-Autoloading" title="Overloading and Autoloading">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
pre.display { font-family:inherit }
pre.format { font-family:inherit }
pre.smalldisplay { font-family:inherit; font-size:smaller }
pre.smallformat { font-family:inherit; font-size:smaller }
pre.smallexample { font-size:smaller }
pre.smalllisp { font-size:smaller }
span.sc { font-variant:small-caps }
span.roman { font-family:serif; font-weight:normal; }
span.sansserif { font-family:sans-serif; font-weight:normal; }
--></style>
</head>
<body>
<div class="node">
<p>
<a name="Private-Functions"></a>
Next: <a rel="next" accesskey="n" href="Overloading-and-Autoloading.html#Overloading-and-Autoloading">Overloading and Autoloading</a>,
Previous: <a rel="previous" accesskey="p" href="Subfunctions.html#Subfunctions">Subfunctions</a>,
Up: <a rel="up" accesskey="u" href="Function-Files.html#Function-Files">Function Files</a>
<hr>
</div>
<h4 class="subsection">11.7.3 Private Functions</h4>
<p>In many cases one function needs to access one or more helper
functions. If the helper function is limited to the scope of a single
function, then subfunctions as discussed above might be used. However,
if a single helper function is used by more than one function, then
this is no longer possible. In this case the helper functions might
be placed in a subdirectory, called "private", of the directory in which
the functions needing access to this helper function are found.
<p>As a simple example, consider a function <code>func1</code>, that calls a helper
function <code>func2</code> to do much of the work. For example
<pre class="example"> function y = func1 (x)
y = func2 (x);
endfunction
</pre>
<p class="noindent">Then if the path to <code>func1</code> is <code><directory>/func1.m</code>, and if
<code>func2</code> is found in the directory <code><directory>/private/func2.m</code>,
then <code>func2</code> is only available for use of the functions, like
<code>func1</code>, that are found in <code><directory></code>.
</body></html>
|