Groups | Search | Server Info | Login | Register


Groups > comp.lang.awk > #10013

Re: GAWK mystery parses

From Kaz Kylheku <643-408-1753@kylheku.com>
Newsgroups comp.lang.awk
Subject Re: GAWK mystery parses
Date 2025-10-03 06:20 +0000
Organization A noiseless patient Spider
Message-ID <20251002231443.863@kylheku.com> (permalink)
References <10bnjs1$br9v$1@news.xmission.com>

Show all headers | View raw


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

Back to comp.lang.awk | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

GAWK mystery parses gazelle@shell.xmission.com (Kenny McCormack) - 2025-10-03 04:36 +0000
  Re: GAWK mystery parses Kaz Kylheku <643-408-1753@kylheku.com> - 2025-10-03 06:20 +0000
    Re: GAWK mystery parses gazelle@shell.xmission.com (Kenny McCormack) - 2025-10-03 07:06 +0000

csiph-web