Scope modifiers: Difference between revisions

Added 11l
(→‎{{header|Lua}}: added Lua solution)
(Added 11l)
Line 7:
Show the different scope modifiers available in your language and briefly explain how they change the scope of their variable or function.
If your language has no scope modifiers, note it.
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>V x = ‘From global scope’
 
F outerfunc()
V x = ‘From scope at outerfunc’
 
F scoped_local()
V x = ‘scope local’
R ‘scoped_local scope gives x = ’x
print(scoped_local())
 
F scoped_nonlocal()
R ‘scoped_nonlocal scope gives x = ’@x
print(scoped_nonlocal())
 
F scoped_global()
R ‘scoped_global scope gives x = ’:x
print(scoped_global())
 
outerfunc()</lang>
 
{{out}}
<pre>
scoped_local scope gives x = scope local
scoped_nonlocal scope gives x = From scope at outerfunc
scoped_global scope gives x = From global scope
scoped_notdefinedlocally scope gives x = From scope at outerfunc
</pre>
 
=={{header|Ada}}==
1,481

edits