# HG changeset patch # User Mike Miller # Date 1392875054 18000 # Node ID 477b5916cafe6ac63ba7ef85750b7b5f514074a1 # Parent 4c2465444a96683fd7bf3e612d2b25b61332cb04 doc: Update function locking section with correct usage of mlock (bug #41627) * func.txi (Function Locking): Update description of function locking to show correct usage of the mlock function. diff -r 4c2465444a96 -r 477b5916cafe doc/interpreter/func.txi --- a/doc/interpreter/func.txi Tue Feb 18 09:59:52 2014 -0500 +++ b/doc/interpreter/func.txi Thu Feb 20 00:44:14 2014 -0500 @@ -1052,18 +1052,22 @@ As an example, @example -mlock ("my_function"); +@group +function my_function () + mlock (); + @dots{} +@end group @end example @noindent -prevents @code{my_function} from being removed from memory, even if -@code{clear} is called. It is possible to determine if a function is -locked into memory with the @code{mislocked}, and to unlock a function -with @code{munlock}, which the following illustrates. +prevents @code{my_function} from being removed from memory after it is +called, even if @code{clear} is called. It is possible to determine if +a function is locked into memory with the @code{mislocked}, and to unlock +a function with @code{munlock}, which the following illustrates. @example @group -mlock ("my_function"); +my_function (); mislocked ("my_function") @result{} ans = 1 munlock ("my_function"); @@ -1078,11 +1082,11 @@ @example @group function count_calls () + mlock (); persistent calls = 0; printf ("'count_calls' has been called %d times\n", ++calls); endfunction -mlock ("count_calls"); count_calls (); @print{} 'count_calls' has been called 1 times @@ -1093,22 +1097,6 @@ @end group @end example -@noindent -It is, however, often inconvenient to lock a function from the prompt, -so it is also possible to lock a function from within its body. This -is simply done by calling @code{mlock} from within the function. - -@example -@group -function count_calls () - mlock (); - persistent calls = 0; - printf ("'count_calls' has been called %d times\n", - ++calls); -endfunction -@end group -@end example - @code{mlock} 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.