[Top][All Lists]

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

Re: Bug with PROCINFO["identifiers"]

From: arnold
Subject: Re: Bug with PROCINFO["identifiers"]
Date: Thu, 03 Sep 2020 04:10:42 -0600
User-agent: Heirloom mailx 12.5 7/5/10


Thanks for taking the time to send in a bug report.

anoncoward--- via "Bug reports and all discussion about gawk." 
<bug-gawk@gnu.org> wrote:

> If one has a user defined variable (scalar or array), 
> PROCINFO["identifiers"] always returns ``untyped'' 
> even if the type is known.
> (Hushmail will wrap the lines.  My apologies.)
> $ LC_ALL=C ./gawk 'BEGIN {s="a"; i=1; ar[1]=3; print 
> PROCINFO["identifiers"]["s"], PROCINFO["identifiers"]["i"],  
> PROCINFO["identifiers"]["ar"] }'
> untyped untyped untyped
> but the program obviously knows that s and i are scalars and ar is 
> an array.  For example,
> $ LC_ALL=C ./gawk 'BEGIN {s="a"; i=1; ar[1]=3; print typeof(s), 
> typeof(i),  typeof(ar) }'
> string number array
> Per your request, I compiled the latest version of gawk and tested 
> it.

PROCINFO["identifiers"] is built after the program is parsed but
before it starts to run.  typeof is called during execution, when
the variables types have settled down, so it "knows" more.

The manual is pretty clear about this.

But that said, it may be possible to make gawk a little bit smarter
about this, so that it says "untyped" in fewer instances. I will
take a look at it.



reply via email to

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