Groups | Search | Server Info | Login | Register


Groups > comp.lang.awk > #9815

Re: {} Questions

From porkchop@invalid.foo (Mike Sanders)
Newsgroups comp.lang.awk
Subject Re: {} Questions
Date 2024-08-21 18:57 +0000
Organization A noiseless patient Spider
Message-ID <va5das$3vg5l$1@dont-email.me> (permalink)
References <va3ua5$3ohv3$2@dont-email.me> <87o75mpaec.fsf@bsb.me.uk> <va4k6f$3rl80$1@dont-email.me> <va4lb8$3rq72$1@dont-email.me>

Show all headers | View raw


Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

> On 21.08.2024 13:48, Mike Sanders wrote:
>> 
> 
> [ Concerning the basic awk syntax:  condition { action }  ]
> 
>> And yet there's still more implied nuance somehow. Let me try to articulate
>> my thoughts...
>> 
>> - These types of constructs are 'auto' ran per line of input (assuming
>>   its not located within another user-written function) that I get.
> 
> You cannot have these constructs with their given semantics inside a
> function. You'd have to formulate them explicitly (in the imperative
> form) with 'if', as in
> 
>   function f ()
>   {
>       if (condition) action
>   }

Of course I tried & failed eariler today...

   function foo() {

      !boo { code }
   }
 
>>   Perhaps a potential efficiency hit to be aware of.
>> 
>> - There's also the scope of variables to consider... Because any
>>   variable's located outside of a user-written function or conversely
>>   located within a 'bare naked' construct is global, or at least
>>   exposed to the entire script's 'world', so I want be careful here...
> 
> All variables have global scope, with the exception of those specified
> in a function argument list along with the real arguments, as in
> 
>   function f (arg1, arg2,   local1, local2)  { global = arg1 ; ... }
>   f ("Hello", 42);
> 
> (There's some caveat with arrays in the function argument list.)
> 
> Janis

Not sure why that would be, can you offer more detail?

At any rate, as always thanks for the brainfood.

-- 
:wq
Mike Sanders

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