Scope modifiers: Difference between revisions

Content added Content deleted
(Nimrod -> Nim)
No edit summary
Line 347: Line 347:
=={{header|E}}==
=={{header|E}}==
E has no scope modifiers; all variables (including function definitions) are lexical. When more than one file is involved, all import/export of definitions is handled by explicit return values, parameters, or reified environments.
E has no scope modifiers; all variables (including function definitions) are lexical. When more than one file is involved, all import/export of definitions is handled by explicit return values, parameters, or reified environments.

=={{header|Eiffel}}==
Routines (i.e. functions and procedures) always have global scope.

Variables have global scope except for:
* routine parameters
* variables declared local to a routine
* the 'Result' of a function

A local variable cannot hide (have the same name as):
* any routine
* a global variable

<lang Eiffel>feature
some_procedure(int: INTEGER; char: CHARACTER)
local
r: REAL
i: INTEGER
do
-- r, i and s have scope here
-- as well as int and char
-- some_procedure and some_function additionally have scope here
end

s: STRING

some_function(int: INTEGER): INTEGER
do
-- s and Result have scope here
-- as well as int (int here differs from the int of some_procedure)
-- some_procedure and some_function additionally have scope here
end

-- s, some_procedure and some_function have scope here</lang>


=={{header|Ela}}==
=={{header|Ela}}==