Naming Rules (The GNU Awk User’s Guide)
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
awkreserved word (such asiforfor), 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
awknamespace, the names of the additionalgawkbuilt-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
gawkbuilt-in functions may still be called from outside theawknamespace 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
gawkpre-defined variable names may be used:NF::NRis valid, if possibly not all that useful.