Groups | Search | Server Info | Login | Register


Groups > comp.lang.awk > #9809

Re: {} Questions

Path csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Ben Bacarisse <ben@bsb.me.uk>
Newsgroups comp.lang.awk
Subject Re: {} Questions
Date Wed, 21 Aug 2024 09:06:51 +0100
Organization A noiseless patient Spider
Lines 36
Message-ID <87o75mpaec.fsf@bsb.me.uk> (permalink)
References <va3ua5$3ohv3$2@dont-email.me>
MIME-Version 1.0
Content-Type text/plain
Injection-Date Wed, 21 Aug 2024 10:06:51 +0200 (CEST)
Injection-Info dont-email.me; posting-host="fbbdc6bc93fc8e09c145618243cc2ab3"; logging-data="3991012"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Oer+vjN2va+0HOYpjg/IIQD3x3dRMbUs="
User-Agent Gnus/5.13 (Gnus v5.13)
Cancel-Lock sha1:RMvVTrSm8xFhpOs2PBcZI+YCnfM= sha1:lVOkr6Ngdxs2LcP22dFJvdMtqHY=
X-BSB-Auth 1.a8921877f7e2dfd9c8c7.20240821090651BST.87o75mpaec.fsf@bsb.me.uk
Xref csiph.com comp.lang.awk:9809

Show key headers only | View raw


porkchop@invalid.foo (Mike Sanders) writes:

> Assuming any awk variant...
>
> 1. Is this valid? (it works with mawk, gawk, busy box awk)
>
>    BEGIN { debug = 1 }
>
>    (debug)  { code_here }
>
>    (!debug) { code_here }
>
>    END { ... }

Yes, that's valid.  You don't need the ()s round the expressions.

> 2. what is the name or accepted term in AWK for unamed functions,
> main()?

I don't know what you mean.  Can you give an example?

It occurs to me that maybe you think

  (debug) { code }

is a function?  It's not.  It's just a normal pattern/action AWK pair.
An AWK pattern can just be an expression.  That expression is evaluated
for every input line and, if true, the corresponding action is executed.
You could have written

  debug != 0 { code }

instead.

-- 
Ben.

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


Thread

{} Questions porkchop@invalid.foo (Mike Sanders) - 2024-08-21 05:35 +0000
  Re: {} Questions Ben Bacarisse <ben@bsb.me.uk> - 2024-08-21 09:06 +0100
    Re: {} Questions porkchop@invalid.foo (Mike Sanders) - 2024-08-21 11:48 +0000
      Re: {} Questions Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-08-21 14:08 +0200
        Re: {} Questions Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-08-21 14:10 +0200
        Re: {} Questions porkchop@invalid.foo (Mike Sanders) - 2024-08-21 18:57 +0000
          Re: {} Questions Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-08-22 00:51 +0200
      Re: {} Questions Ben Bacarisse <ben@bsb.me.uk> - 2024-08-21 16:38 +0100
        Re: {} Questions porkchop@invalid.foo (Mike Sanders) - 2024-08-21 19:01 +0000

csiph-web