Gawk/Naming-Rules
From Get docs
Next: Internal Name Management, Previous: Changing The Namespace, Up: Namespaces [Contents][Index]
15.5 Namespace and Component Naming Rules
A number of rules apply to the namespace and component names, as follows.
- It is a syntax error to use qualified names for function parameter names.
- It is a syntax error to use any standard
awk
reserved word (such asif
orfor
), or the name of any standard built-in function (such assin()
orgsub()
) as either part of a qualified name. Thus, the following produces a syntax error:@namespace "example" function gsub(str, pat, result) { … }
- Outside the
awk
namespace, the names of the additionalgawk
built-in functions (such asgensub()
orstrftime()
) 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. The additional
gawk
built-in functions may still be called from outside theawk
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.