bug-gawk
[Top][All Lists]
Advanced

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

Re: Not real bugs?


From: arnold
Subject: Re: Not real bugs?
Date: Mon, 08 Jan 2024 01:21:37 -0700
User-agent: Heirloom mailx 12.5 7/5/10

Hi.

In the future, full programs and a statement of what you expect
to see would help.  This is a little bit too stream of consciousness
to give very concrete answers, but I will try.

J Naman <jnaman2@gmail.com> wrote:

> I was looking for a global array in the "awk" namespace. This is arguably a
> coding abuse rather than a real bug.
> # single quote is used in output to replace \", for readability
> # since PROCINFO["identifiers"] is "not updated while the program runs."
> # it might be available for (ab)use like any other array ...
> PROCINFO['identifiers']['foo']=''
> PROCINFO['identifiers']['foo']='untyped'
> PROCINFO['identifiers']['foo']='7'
> typeof(PROCINFO['identifiers']['foo']='number'

It is abusable, but doing so has no effect. It's populated
when gawk parses the program and is there only for information.

> Try using new identifier, "farr" as an array
> typeof(PROCINFO['identifiers']['farr']='untyped'
> PROCINFO['identifiers']['farr'][0]='1'
> PROCINFO['identifiers']['farr'][1]='LIFO string 1'
> typeof(PROCINFO['identifiers']['farr']='array'
>
> PROCINFO['#stack'][0]='0'
> PROCINFO['#stack'][1]='LIFO string 1'
> typeof(PROCINFO['#stack']='array'
>
> # as expected, neither "farr" nor "#stack" are in SYMTAB\

Exactly.

> Separate very minor issue: It is not documented that PROCINFO["-",
> "NONFATAL"] appears to assume SUBSEP = "\034", which it is before the BEGIN
> block executes

It doesn't need to be. There's enough documentation as to how
simulated multidimensional arrays work, and this is one. The manual
already says that the current value of SUBSEP is used when elements
are created and when they're accessed. If you change SUBSEP in
between, it's your problem to deal with.

Arnold



reply via email to

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