|
|
Line 662: |
Line 662: |
|
>>></lang> |
|
>>></lang> |
|
More information on the scope modifiers can be found [http://docs.python.org/3.0/reference/simple_stmts.html#grammar-token-global_stmt here].<br> |
|
More information on the scope modifiers can be found [http://docs.python.org/3.0/reference/simple_stmts.html#grammar-token-global_stmt here].<br> |
|
|
|
⚫ |
|
|
⚫ |
In the REXX language, all variables are local, and only within PROCEDUREs are variables local (private), except |
|
⚫ |
<br>for those identified via the EXPOSE option. There is a variant where the EXPOSE can have a list specified. |
|
⚫ |
<br>Any REXX variables in an external routine (program) aren't known. |
|
⚫ |
<br>Note: the R4 REXX interpreter has an '''EXPOSEALL''' option that allows an external REXX subroutine to access the caller's local variables. |
|
⚫ |
<br>There is a mechanism that allows external programs to access local REXX variables and is essentially restricted to |
|
⚫ |
<br>assembler programs that use the REXXAPI interface. |
|
⚫ |
<br>All labels (names of subroutines/functions/procedures) are global. |
|
⚫ |
<br>If more than one identical label is specified, only the first label is recognized (and not considered an error). |
|
⚫ |
<lang rexx>/*REXX program to display scope modifiers (for subroutines/functions). */ |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
/* at this point, A is defined and equal to .25 */ |
|
⚫ |
/* at this point, B is defined and equal to 40 */ |
|
⚫ |
/* at this point, C is defined and equal to 27 */ |
|
⚫ |
/* at this point, D is defined and equal to 5 */ |
|
⚫ |
/* at this point, FF isn't defined. */ |
|
⚫ |
/* at this point, EWE is defined and equal to 'female sheep' */ |
|
⚫ |
/* at this point, G is defined and equal to 625 */ |
|
⚫ |
exit /*stick a fork in it, we're done.*/ |
|
⚫ |
/*─────────────────────────────────────SSN_571 submarine, er, subroutine*/ |
|
⚫ |
SSN_571: procedure expose b c ewe g; parse arg g |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
return /*compliments to Jules Verne's Captain Nemo? */</lang> |
|
|
|
|
|
|
=={{header|R}}== |
|
=={{header|R}}== |
Line 810: |
Line 777: |
|
|
|
|
|
However, Racket identifier bindings do exist at particular phase levels (represented by an integer). Phase levels, to a first approximation, allow the separation of computations that occur at compile-time and run-time. |
|
However, Racket identifier bindings do exist at particular phase levels (represented by an integer). Phase levels, to a first approximation, allow the separation of computations that occur at compile-time and run-time. |
|
|
|
|
⚫ |
|
|
⚫ |
In the REXX language, all variables are local, and only within PROCEDUREs are variables local (private), except |
|
⚫ |
<br>for those identified via the EXPOSE option. There is a variant where the EXPOSE can have a list specified. |
|
⚫ |
<br>Any REXX variables in an external routine (program) aren't known. |
|
⚫ |
<br>Note: the R4 REXX interpreter has an '''EXPOSEALL''' option that allows an external REXX subroutine to access the caller's local variables. |
|
⚫ |
<br>There is a mechanism that allows external programs to access local REXX variables and is essentially restricted to |
|
⚫ |
<br>assembler programs that use the REXXAPI interface. |
|
⚫ |
<br>All labels (names of subroutines/functions/procedures) are global. |
|
⚫ |
<br>If more than one identical label is specified, only the first label is recognized (and not considered an error). |
|
⚫ |
<lang rexx>/*REXX program to display scope modifiers (for subroutines/functions). */ |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
|
|
|
⚫ |
/* at this point, A is defined and equal to .25 */ |
|
⚫ |
/* at this point, B is defined and equal to 40 */ |
|
⚫ |
/* at this point, C is defined and equal to 27 */ |
|
⚫ |
/* at this point, D is defined and equal to 5 */ |
|
⚫ |
/* at this point, FF isn't defined. */ |
|
⚫ |
/* at this point, EWE is defined and equal to 'female sheep' */ |
|
⚫ |
/* at this point, G is defined and equal to 625 */ |
|
⚫ |
exit /*stick a fork in it, we're done.*/ |
|
⚫ |
/*─────────────────────────────────────SSN_571 submarine, er, subroutine*/ |
|
⚫ |
SSN_571: procedure expose b c ewe g; parse arg g |
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
|
|
⚫ |
return /*compliments to Jules Verne's Captain Nemo? */</lang> |
|
|
|
|
|
=={{header|Tcl}}== |
|
=={{header|Tcl}}== |
|
===Variables=== |
|
===Variables=== |
|
In Tcl procedures, variables are local to the procedure unless explicitly declared otherwise (unless they contain namespace separators, which forces interpretation as namespace-scoped names). Declarations may be used to access variables in the global namespace, or the current namespace, or indeed any other namespace. |
|
In Tcl procedures, variables are local to the procedure unless explicitly declared otherwise (unless they contain namespace separators, which forces interpretation as namespace-scoped names). Declarations may be used to access variables in the global namespace, or the current namespace, or indeed any other namespace. |
|
|
|
|
{{works with|Tcl|8.5}} |
|
{{works with|Tcl|8.5}} |
|
<lang tcl>set globalVar "This is a global variable" |
|
<lang tcl>set globalVar "This is a global variable" |