bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Postdecrementing $NF


From: arnold
Subject: Re: [bug-gawk] Postdecrementing $NF
Date: Sun, 08 Sep 2013 12:14:38 -0600
User-agent: Heirloom mailx 12.4 7/29/08

Davide Brini <address@hidden> wrote:

> But then why using a variable in the same way works as expected?
>
> $ echo a b c | awk '{ a = NF; print $(a--) }'
> c

Because decrementing NF has special semantics defined by the
language to affect the fields and $0. Regular variables don't
have those special, "magic" semantics.

(In other words, decrementing NF has additional side effects above
and beyond changing the value of NF itself. Any assignment to NF does.)

Arnold



reply via email to

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