bug-gawk
[Top][All Lists]
Advanced

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

Re: Error in GAWK: Effective AWK Programming user guide


From: arnold
Subject: Re: Error in GAWK: Effective AWK Programming user guide
Date: Sun, 06 Aug 2023 11:07:47 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Hi.

Thank you for taking the time to report an issue.  The GNU webmasters
forwarded your note to me.  In the future you can send such reports to
the bug list.

With respect to what you've written, the text in the gawk manual
is correct as written. Expressions used for function parameters
are completely evaluated before the function is called. This can
be more clearly seen with user defined functions. For example:

        $ cat x.awk
        function myfunc(local_i)
        {
                print "local_i =", local_i
                print "global_i =", i
        }

        BEGIN {
                i = 4
                myfunc(i++)
        }

        $ gawk -f x.awk
        local_i = 4
        global_i = 5

Thanks,

Arnold

Le Ven 04 Aoû 2023 22:30:41, george.bromell@outlook.com a écrit :
> Hi.
> 
> I am writing to point out an error in the user guide for GAWK. This
> error exists in edition 4.1 and 5.2 (that I have looked at) and can be
> found in section 9, Calling Built-in Functions.
> 
> Paragraph 4 reads, "For example, in the following code fragment: i = 4
> j = sqrt(i++) the variable i is incremented to the value five before
> sqrt() is called with a value of four for its actual parameter."
> 
> When it should read, "For example, in the following code fragment: i =
> 4 j = sqrt(i++) the variable i is incremented to the value five after
> sqrt() is called with a value of four for its actual parameter."
> 
> See code execution example below.
> 
> $ awk 'BEGIN {
> > i=4
> > j=sqrt(i++)
> > print j
> > print i
> > }'
> 5
> 2
> 
> Thanks for a great reference resource.
> 
> Regards George



reply via email to

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