Scope/Function names and labels: Difference between revisions
Content deleted Content added
initial draft |
m awk |
||
Line 3: | Line 3: | ||
The task is to explain or demonstrate the levels of visibility of function names and labels within the language. |
The task is to explain or demonstrate the levels of visibility of function names and labels within the language. |
||
For levels of scope relating to visibility of variables see [[Variables]]. |
For levels of scope relating to visibility of variables see [[Variables]]. |
||
For scope modification facilities see [[Scope modifiers]]. |
|||
{{ |
{{lang|AWK}} |
||
In [awk] function names are always global and can be referenced in sections of code appearing before the definition: |
|||
<lang awk># This program outputs a greeting |
|||
BEGIN { |
|||
sayhello() # Call the function defined below |
|||
exit |
|||
} |
|||
function sayhello { |
|||
print "Hello World!" # Outputs a message to the terminal |
|||
}</lang> |
|||
Note that the awk extraction and reporting language is data driven and does not support arbitary line labels. |
|||
{{omit from|GUISS|does not have functions or labels}} |
|||
[[Category:Scope]] |
[[Category:Scope]] |
Revision as of 23:44, 18 February 2013
Scope/Function names and labels is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.
The task is to explain or demonstrate the levels of visibility of function names and labels within the language.
For levels of scope relating to visibility of variables see Variables. For scope modification facilities see Scope modifiers.
In [awk] function names are always global and can be referenced in sections of code appearing before the definition:
<lang awk># This program outputs a greeting
BEGIN { sayhello() # Call the function defined below exit }
function sayhello { print "Hello World!" # Outputs a message to the terminal }</lang>
Note that the awk extraction and reporting language is data driven and does not support arbitary line labels.