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: Andrew J. Schorr
Subject: Re: [bug-gawk] Access variables not conforming to the variable naming convention?
Date: Mon, 3 Dec 2018 10:52:58 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Dec 03, 2018 at 07:10:30AM -0700, address@hidden wrote:
> > Hmmm, I think he may have something like this in mind:
> >
> > bash-4.2$ cat inp
> > name,age,weight
> > John,23,150
> > Hilda,17,110
> > bash-4.2$ gawk -F, '
> > > NR == 1 {
> > >    for (i = 1; i <= NF; i++)
> > >       SYMTAB[$i] = i
> > >    next
> > > }     
> > > 
> > > $age >= 20 {
> > >    print
> > > }' inp
> > John,23,150
> >
> > Are you disabling that ability to create the variable by poking it into 
> > SYMTAB
> 
> **** THERE IS NO SUCH CAPABILITY ****.  The fact that you reference 'age'
> in the program is what puts it into SYMTAB.

Ah, OK, thanks for clarifying.

> Your program creates unrelated (non-variable) elements in SYMTAB "name"
> and "weight" that are no different from any other array elements.

But with your proposed patch, this program will give a fatal error,
won't it?

> It is exactly this confusion that I'm trying to avoid.

I guess there's a question as to whether this is progress or just breaks
sloppy code. As I said, I don't like this paradigm because it stomps
on the variable namespace, but I suppose others may be using it...

Regards,
Andy



reply via email to

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