bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

documentation inconsistency


From: J Naman
Subject: documentation inconsistency
Date: Wed, 6 Oct 2021 01:14:56 -0400

# this is not a bug, it is a documentation inconsistency that perhaps
# should remain 'undocumented' gawk 5.1.0 Win7 & 5.1.1f Ubuntu 20 something
# 7.4.4 The for Statement: "The initialization, condition, and increment
#       parts are arbitrary awk EXPRESSIONS, and body stands for any awk
#       awk STATEMENT.
#       The for STATEMENT starts by executing initialization.
# ...   "It isn’t possible to set more than one variable in the
#       initialization part without using a multiple assignment statement
#       such as ‘x = y = 0’ statement."
#       <or calling a function that assigns global variable(s)>

BEGIN{
for(init_globals(3) ; foo<6 ; incr_globals(2)){
print "foo= " foo " global2= " global2 " doc= '" doc "'"
}
exit 1
}
# ------------------------
function init_globals(value){ foo=value;  global2=foo+10; doc="Init";}
# ------------------------
function incr_globals(incr){   foo+=incr; global2=foo+10; doc="Increment";}
# ------------------------
# result:
# foo= 3 global2= 13 doc= 'Init'
# foo= 5 global2= 15 doc= 'Increment'
- John Naman  gawker@703n.com


reply via email to

[Prev in Thread] Current Thread [Next in Thread]