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: J Naman
Subject: Re: Inconsistency in Namespace Internal Name Management, Ver 5.1.1
Date: Thu, 30 Dec 2021 19:21:02 -0500

Almost. Consider:
@namespace "ns"
function ns1(){return 1}
function ns::ns2(){return 2}
function awk::defined_in_ns3(){return 3}
@namespace "awk"
function awkspace4(){return 4}
function awk::awkspace5(){return 5}
==================
Your awk::foo() <==> my @namespace "awk"; function awk::awkspace5(){return
5}
Your foo() <==> my @namespace "awk";  function awkspace4(){return 4}
Your set did not include @namespace "ns"; function
awk::defined_in_ns3(){return 3}
which I think would be:
bash-4.2$ gawk '@namespace "ns"; func awk::foo() {print "hello"} BEGIN {for
(i in FUNCTAB) print i; for (i in PROCINFO["identifiers"]) print i}' | grep
foo
foo
awk::foo
The @namespace "not_awk"; func awk::foo() is illustrated by Chap 15.7
Namespace Example # ns_passwd.awk
@namespace "passwd"; function awk::getpwent()
which would give getpwent and awk::getpwent()  # I believe
Okay?

On Thu, Dec 30, 2021 at 4:31 PM Andrew J. Schorr <
aschorr@telemetry-investments.com> wrote:

> 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]