changeset 24953:11b13a7cc57e stable

doc: Document forbidden persistent function input/output arguments (bug #53331). * doc/interpreter/var.txi: Document forbidden persistent function input and output arguments, including a small example.
author Kai T. Ohlhus <k.ohlhus@gmail.com>
date Wed, 21 Mar 2018 22:02:27 +0100
parents 1fbd8afcf625
children a600838cb1c9
files doc/interpreter/var.txi
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/interpreter/var.txi	Wed Mar 21 22:02:27 2018 +0100
+++ b/doc/interpreter/var.txi	Wed Mar 21 22:02:27 2018 +0100
@@ -223,6 +223,20 @@
 The behavior of persistent variables is equivalent to the behavior of
 static variables in C@.
 
+One restriction for persistent variables is, that neither input nor
+output arguments of a function can be persistent:
+
+@example
+@group
+function y = foo ()
+  persistent y = 0;  # Not allowed!
+endfunction
+
+foo ()
+@print{} error: can't make function parameter y persistent
+@end group
+@end example
+
 Like global variables, a persistent variable may only be initialized once.
 For example, after executing the following code