diff options
Diffstat (limited to 'doc/colm/0_06_scope.adoc')
-rw-r--r-- | doc/colm/0_06_scope.adoc | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/doc/colm/0_06_scope.adoc b/doc/colm/0_06_scope.adoc new file mode 100644 index 00000000..2c411a61 --- /dev/null +++ b/doc/colm/0_06_scope.adoc @@ -0,0 +1,69 @@ +Scope +===== + +We saw in the previous paragraph that functions can be used, and that they can have parameter. +This forces us to clarify 'scope'. + +[source,chapel] +./scope.lm +---- +include::code/scope.lm[] +---- + +We run it with +[source,bash] +---- +/opt/colm/bin/colm scope.lm +./scope +---- + +That gives us: +---- +in global global +in A global +in B a +in B b +in A a +in global global +in C NIL +in C c +in global c +---- + +The thesis also mentions that variables can be passed by reference instead of by value. + +[source,chapel] +.nested_scope.lm +---- +include::code/nested_scope.lm[] +---- + +That gives us: +---- +in global global +in A global +in B a +in B b +in A a +in global global +in C NIL +in C c +in global c +---- + +[source,bash] +---- +/opt/colm/bin/colm nested_scope.lm +./nested_scope +---- + +It seems that this is still the case. +---- +in global global +before block1 global +in block1 block1 +in loop block1a +in block1 block1a +in A block1a +in global global +---- |