changeset 12629:8c25df502846 stable

func.txi: document use of nargin checking at head of function.
author Rik <octave@nomad.inbox5.com>
date Fri, 22 Apr 2011 09:28:06 -0700
parents 83606de30dae
children 2dbac27e0e40
files doc/interpreter/func.txi
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/func.txi	Tue Apr 19 21:52:56 2011 -0400
+++ b/doc/interpreter/func.txi	Fri Apr 22 09:28:06 2011 -0700
@@ -338,6 +338,24 @@
 
 @DOCSTRING(nargout)
 
+It is good practice at the head of a function to verify that it has been called
+correctly.  In Octave the following idiom is seen frequently
+
+@example
+@group
+if (nargin < min_#_inputs || nargin > max_#_inputs)
+  print_usage ();
+endif
+@end group
+@end example
+
+@noindent
+which stops the function execution and prints a message about the correct
+way to call the function whenever the number of inputs is wrong.
+
+For compatability with @sc{matlab}, @code{nargchk} and @code{nargoutchk} are
+available which provide similar error checking.
+
 @DOCSTRING(nargchk)
 
 @DOCSTRING(nargoutchk)