summaryrefslogtreecommitdiff
path: root/doc/0_06_scope.adoc
diff options
context:
space:
mode:
Diffstat (limited to 'doc/0_06_scope.adoc')
-rw-r--r--doc/0_06_scope.adoc56
1 files changed, 2 insertions, 54 deletions
diff --git a/doc/0_06_scope.adoc b/doc/0_06_scope.adoc
index 5025052c..2c411a61 100644
--- a/doc/0_06_scope.adoc
+++ b/doc/0_06_scope.adoc
@@ -7,38 +7,7 @@ This forces us to clarify 'scope'.
[source,chapel]
./scope.lm
----
-str d (where:str) {
- print( "in D ", where, "\n")
- where = "d"
- print( "in D ", where, "\n")
-}
-
-str c ( ) {
- print( "in C ", where_g, "\n")
- where_g = "c"
- print( "in C ", where_g, "\n")
-}
-
-str b ( where:str ) {
- print( "in B ", where, "\n")
- where = "b"
- print( "in B ", where, "\n")
-}
-
-str a( where:str ) {
- print( "in A ", where, "\n")
- where = "a"
- b( where )
- print( "in A ", where, "\n")
-}
-
-where: str = "global"
-print( "in global ", where, "\n")
-a( where )
-print( "in global ", where, "\n")
-global where_g:str
-c( )
-print( "in global ", where_g, "\n")
+include::code/scope.lm[]
----
We run it with
@@ -66,28 +35,7 @@ The thesis also mentions that variables can be passed by reference instead of by
[source,chapel]
.nested_scope.lm
----
-str a( where:str ) {
- print( "before block1 ", where, "\n" )
- while(true) {
- where = "block1"
- print( "in block1 ", where, "\n" )
- i:int = 0
- while( true ) {
- where = where + "a"
- print( "in loop ", where, "\n" )
- break
- }
- print( "in block1 ", where, "\n" )
- break
- }
- print( "in A ", where, "\n" )
- return where
-}
-
-where: str = "global"
-print( "in global ", where, "\n" )
-a( where )
-print( "in global ", where, "\n" )
+include::code/nested_scope.lm[]
----
That gives us: