From Newsgroup: comp.lang.awk
On 2025-10-03, Kenny McCormack <
gazelle@shell.xmission.com> wrote:
The topic for today is: What can we get away with for clause 3 of a "for" statement.
Observe (notice that the print statement is *inside* the for statement):
First, we use a print statement as clause 3:
% gawk4 'BEGIN { for (i=1; i<=5; print "i =",i++); }'
i = 1
i = 2
i = 3
i = 4
i = 5
That's interesting, and useless; yet, stupidly, you cannot have comma expressions like for (i = 0, j = 0; ...
What you found is not portable:
$ mawk 'BEGIN { for (i=1; i<=5; print "i =",i++); }'
mawk: line 1: syntax error at or near print
--
TXR Programming Language:
http://nongnu.org/txr
Cygnal: Cygwin Native Application Library:
http://kylheku.com/cygnal
Mastodon: @
Kazinator@mstdn.ca
--- Synchronet 3.21a-Linux NewsLink 1.2