bug-gawk
[Top][All Lists]
Advanced

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

Re: Inconsistency in Namespace Internal Name Management, Ver 5.1.1


From: Andrew J. Schorr
Subject: Re: Inconsistency in Namespace Internal Name Management, Ver 5.1.1
Date: Thu, 30 Dec 2021 16:31:29 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Thu, Dec 30, 2021 at 03:54:50PM -0500, J Naman wrote:
> Ref: 15.6 Internal Name Management (in Namespaces)
> "For backwards compatibility, all identifiers in the awk namespace are
> stored internally as
> unadorned identifiers (that is, without a leading ‘awk::’). This is mainly
> relevant when
> using such identifiers as indices for SYMTAB, FUNCTAB, and
> PROCINFO["identifiers"]"
> 
> The above is True for user-defined functions (UDFs)
> defined with a namespace qualified name, i.e. ns::foo()
> @namespace "ns"
> ns::foo is YES in FUNCTAB
> ns::foo is YES in PROCINFO["identifiers"];
> 
> *NOT True* for UDFs defined with awk namespace qualified name, i.e.
> awk::foo()
> 
> "awk::foo" is NOT in FUNCTAB
> "awk::foo" is YES in PROCINFO["identifiers"];
> 
>      "foo" is YES in FUNCTAB
>      "foo" is NOT in PROCINFO["identifiers"];
> 
> Note: the above awk::foo() and foo()
> *will execute correctly, whether calleddirectly or indirectly,* without
> regard to their showing as 'in FUNCTAB' or
> PROCINFO["identifiers"];

Interesting. Do these examples capture the issue you have in mind?

bash-4.2$ gawk '@namespace "ns"; func foo() {print "hello"} BEGIN {for (i in 
FUNCTAB) print i; for (i in PROCINFO["identifiers"]) print i}' | grep foo
ns::foo
ns::foo

bash-4.2$ gawk 'func ns::foo() {print "hello"} BEGIN {for (i in FUNCTAB) print 
i; for (i in PROCINFO["identifiers"]) print i}' | grep foo
ns::foo
ns::foo

bash-4.2$ gawk 'func awk::foo() {print "hello"} BEGIN {for (i in FUNCTAB) print 
i; for (i in PROCINFO["identifiers"]) print i}' | grep foo
foo
awk::foo

bash-4.2$ gawk 'func foo() {print "hello"} BEGIN {for (i in FUNCTAB) print i; 
for (i in PROCINFO["identifiers"]) print i}' | grep foo
foo
foo

Regards,
Andy



reply via email to

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