Next: Internal Name Management, Previous: Changing The Namespace, Up: Namespaces [Contents][Index]
A number of rules apply to the namespace and component names, as follows.
awk
reserved word (such
as if
or for
), or the name of any standard built-in function
(such as sin()
or gsub()
) as either part of a qualified name.
Thus, the following produces a syntax error:
@namespace "example" function gsub(str, pat, result) { … }
awk
namespace, the names of the additional gawk
built-in functions (such as gensub()
or strftime()
) may
be used as component names. The same set of names may be used as namespace
names, although this has the potential to be confusing.
gawk
built-in functions may still be called
from outside the awk
namespace by qualifying them. For example,
awk::systime()
. Here is a somewhat silly example demonstrating
this rule and the previous one:
BEGIN { print "in awk namespace, systime() =", systime() } @namespace "testing" function systime() { print "in testing namespace, systime() =", awk::systime() } BEGIN { systime() }
When run, it produces output like this:
$ gawk -f systime.awk -| in awk namespace, systime() = 1500488503 -| in testing namespace, systime() = 1500488503
gawk
pre-defined variable names may be used:
NF::NR
is valid, if possibly not all that useful.