Scope/Function names and labels: Difference between revisions

Added Algol 68
(Added Axe)
(Added Algol 68)
Line 5:
* [[Variables]] for levels of scope relating to visibility of program variables
* [[Scope modifiers]] for general scope modification facilities
 
=={{header|ALGOL 68}}==
Algol 68 follows the traditional block structure scoping rules introduced by Algol 60.
<br>
A label, function (PROC), variable etc. declared in an outer block is only visible within that block and all inner blocks,
unless another label, function, etc. is declared with the same name in an inner block.
<br>
In addition, functions etc. declared between IF and THEN are in scope in the THEN and ELSE parts, but
declarations in the THEN part and not visible in the ELSE part (and vice versa), so the following is invalid:
<lang algol68>IF PROC x = ...;
...
THEN
# can call x here #
PROC y = ...;
...
GO TO l1 # invalid!! #
ELSE
# can call x here, but not y #
...
l1: ...
FI</lang>
Similarly, declarations between WHILE and DO are in scope between DO and OD and those declared between CASE and IN are visible in the IN and OUT parts of a CASE.
<br>
Note that labels cannot be defined between IF and THEN, between WHILE and DO and between CASE and IN.
 
=={{header|AWK}}==
3,038

edits