bug-gawk
[Top][All Lists]
Advanced

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

Re: [PATCH] Feature: @local declares local variables


From: J Naman
Subject: Re: [PATCH] Feature: @local declares local variables
Date: Wed, 13 Apr 2022 12:50:01 -0400

I have been offline for some time and just read the threads about local and
block-level variables. Perhaps I am way off base, but it sounds like much
of this discussion can be subsumed under @namespace. IF there were
block-level or function-level namespaces, certain variables might have a
longer life than local variables. Arnold clearly states, "There is no
concept of a “current” namespace once your program starts executing."[man
15.4], but that API-extensions can have a namespace shared by cooperating
awk and C code and extensions have
Symbol table access: retrieving a global variable, creating one, or
changing one.
That sounds like it might be possible to declare a @local variable and use
it, presumably creating a "current" namespace for that variable. Such as:
function foo(){ local(x); # creates foo::x on the fly
...}
I am NOT advocating this, obviously it is fraught with risks to be growing
the symbol table, just saying it seems like something can be done within
GAWK, without forking, by use of the well-thought out extension capability.
If I am totally off base, delete this and sorry for wasting time. -john


reply via email to

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