[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Postdecrementing $NF
From: |
Aharon Robbins |
Subject: |
Re: [bug-gawk] Postdecrementing $NF |
Date: |
Mon, 09 Sep 2013 21:23:40 +0200 |
User-agent: |
Heirloom mailx 12.5 6/20/10 |
Hi.
> Date: Sun, 08 Sep 2013 20:20:28 +0200
> From: Manuel Collado <address@hidden>
> To: address@hidden
> Subject: Re: [bug-gawk] Postdecrementing $NF
>
> [............]
>
> > I don't believe that one behavior is more "correct" than the other;
> > of four different awks that I tested, including gawk, two do it the
> > one way, and two do it the other.
>
> The second behavior is probably the "correct" one. It it dubious to use the
> value of a parenthesized subexpression before fully evaluating it.
"Correct" in this context means "what POSIX would expect". I don't think
POSIX says anything. Taking "correct" to be "what is the best thing for
the language to do" then I agree, gawk's current behavior is more correct.
But I do understand why one might expect the other behavior.
> The real undefined behavior issue is if decrementing NF should in fact drop
> the last field, I.e., if decrementing the read-only NF variable should
> affect the access to the original fields, or just modify a local user
> visible copy of NF.
Not sure what you're trying to say here. NF is not read only; there
are defined semantics for setting it (increasing it or decreasing it).
I am 99% certain that if I looked I could find chapter and verse on this
in the original awk book and probably in POSIX.
I don't know what you mean by "local user visible copy of NF" --- awk
doesn't have scoping a la perl's "my { ... }" construct. (If that's
what you meant. :-)
Thanks,
Arnold