<html lang="en"> <head> <title>Style Tips - Untitled</title> <meta http-equiv="Content-Type" content="text/html"> <meta name="description" content="Untitled"> <meta name="generator" content="makeinfo 4.13"> <link title="Top" rel="start" href="index.html#Top"> <link rel="up" href="Tips-and-Standards.html#Tips-and-Standards" title="Tips and Standards"> <link rel="next" href="Coding-Tips.html#Coding-Tips" title="Coding Tips"> <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"> <a name="Style-Tips"></a> <p> Next: <a rel="next" accesskey="n" href="Coding-Tips.html#Coding-Tips">Coding Tips</a>, Up: <a rel="up" accesskey="u" href="Tips-and-Standards.html#Tips-and-Standards">Tips and Standards</a> <hr> </div> <h3 class="section">C.1 Writing Clean Octave Programs</h3> <p>Here are some tips for avoiding common errors in writing Octave code intended for widespread use: <ul> <li>Since all global variables share the same name space, and all functions share another name space, you should choose a short word to distinguish your program from other Octave programs. Then take care to begin the names of all global variables, constants, and functions with the chosen prefix. This helps avoid name conflicts. <p>If you write a function that you think ought to be added to Octave under a certain name, such as <code>fiddle_matrix</code>, don't call it by that name in your program. Call it <code>mylib_fiddle_matrix</code> in your program, and send mail to <a href="mailto:maintainers@octave.org">maintainers@octave.org</a> suggesting that it be added to Octave. If and when it is, the name can be changed easily enough. <p>If one prefix is insufficient, your package may use two or three alternative common prefixes, so long as they make sense. <p>Separate the prefix from the rest of the symbol name with an underscore ‘<samp><span class="samp">_</span></samp>’. This will be consistent with Octave itself and with most Octave programs. <li>When you encounter an error condition, call the function <code>error</code> (or <code>usage</code>). The <code>error</code> and <code>usage</code> functions do not return. See <a href="Errors.html#Errors">Errors</a>. <li>Please put a copyright notice on the file if you give copies to anyone. Use the same lines that appear at the top of the function files distributed with Octave. If you have not signed papers to assign the copyright to anyone else, then place your name in the copyright notice. </ul> </body></html>