Ver Fonte

moving/split encapsultion

abakobo há 8 anos atrás
pai
commit
5c9b9adfe7

+ 41 - 8
modules/monkey/docs/articles/multifile-projects.md

@@ -4,14 +4,14 @@
 To add additional source files to a monkey2 project, you use the #Import directive. #Import can also be used to import other stuff into a project, but more on that late
 
 \#Imports should appear at the top of a source file before any declarations occur. #Import takes one parameter – the path to the file to import. If the file is a '.monkey2' file, the extensions can be omitted, eg:
- 
+
 
 ```
 'file1.monkey2
 '
 #Import "file2"
 #Import "file3"
- 
+
 Function Something()
 End
 ```
@@ -29,23 +29,23 @@ Code in any imported monkey2 file can use code in any other imported monkey2 fil
 '
 #Import "file2"
 #Import "file3"
- 
+
 Function Func1()
    Func1()
    Func2()
    Func3()
 End
- 
+
 '***** file2.monkey2 *****
- 
+
 Function Func2()
    Func1()
    Func2()
    Func3()
 End
- 
+
 '***** file3.monkey2 *****
- 
+
 Function Func3()
    Func1()
    Func2()
@@ -55,4 +55,37 @@ End
 
 This is perfectly valid, as long as file1.monkey2 is the ‘root file’ you compile.
 
- 
+You may encapsulate some code within a file by using the `Private` keyword. That code will  only be accessible within the file. The `Public` keyword allows you to go back to the default public privacy level.
+
+```
+'***** file1.monkey2 *****
+'
+#Import "file2"
+
+Function Func1()
+   Func1()
+   Func2()
+   Func3() 'this call is not valid, Func3 is private to file2.monkey!
+   Func4()
+End
+
+'***** file2.monkey2 *****
+
+Function Func2()
+   Func1()
+   Func3() 'here the call is valid
+End
+
+Private 'entering private declarations
+
+Function Func3()
+   'some statements
+End
+
+Public 'back to public declarations
+
+Function Func4()
+   'some statements
+End
+
+```

+ 1 - 1
modules/monkey/docs/language/loop-statements.md

@@ -97,7 +97,7 @@ If Collection is an array, the loop will iterate through each element of the arr
 
 If Collection is a string, the loop will iterate through each character code of the string, and the type of the index variable must be numeric.
 
-If Collection is an object, it must implement the std.collections.Icontainer interface. See <a href=http://monkey2.monkey-x.com/mx2-docs/std-std-collections-icontainer/ target=blank>std-std-collections-icontainer</a>.
+If Collection is an object, it must implement the std.collections.Icontainer interface. See <a href=http://monkeycoder.co.nz/mx2-docs/std-std-collections-icontainer/ target=blank>std-std-collections-icontainer</a>.
 
 #### Exit
 

+ 0 - 25
modules/monkey/docs/language/misc.md

@@ -1,30 +1,5 @@
 ### Miscellaneous
 
-#### File Encapsulation
-
-There are two Levels of encapsulation at .monkey2 source files scope: `Public`and `Private` (`Protected` can only be used inside a class, struct or interface).
-
-`Public` can be accessed from anywhere. It is the default encapsulation level. Code existing in the same source file have also acces to expressions declared as `Private`.
-
-example:
-```
-Namespace myapp
-#Import "<std>"
-Using std..
-
-Function Main()
-	SayHello()
-End
-
-Private 'this section won't be accessible in other imported files
-
-Function SayHello()
-  Print "Hello"
-End
-```
-see also
-/linto Articles-and-tutorials/Multifiles-projects-and-#import \linkto
-
 #### Code lines splitting
 
 Lines can currently only be split after ‘[‘, ‘(‘ or ‘,’ tokens.