bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Access variables not conforming to the variable naming co


From: arnold
Subject: Re: [bug-gawk] Access variables not conforming to the variable naming convention?
Date: Sun, 02 Dec 2018 23:57:40 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Peng Yu <address@hidden> wrote:

> > > please don't do that about SYMTAB :)
> >
> > Why not? Please give a good reason.
>
> A specific example that I have is to parse a headed TSV file and refer
> to columns by header names (all of these preprocessing are loaded as
> premade awk files, so users don't need to know $1 $2 any more to refer
> to columns). Without SYMTAB, it is impossible to do so.

I was not clear about my intent.  The following continues to work
as intended:

        $ ./gawk 'BEGIN { foo = 5
        > SYMTAB["foo"] += 37
        > print foo }'
        42

Whereas this no longer works as it did previously:

        $ ./gawk 'BEGIN { foo = 5
        > SYMTAB["the answer"] = 42
        > print SYMTAB["the answer"] }'
        gawk: cmd. line:2: fatal: cannot assign to arbitrary elements of SYMTAB

So existing code that used SYMTAB to update a variable will continue
to work.

Thanks,

Arnold



reply via email to

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