2
0
Эх сурвалжийг харах

internal + class ptr removed

abakobo 7 жил өмнө
parent
commit
b4f57770f9

+ 13 - 0
modules/monkey/newdocs/language/misc.md

@@ -10,6 +10,8 @@ Inline comments can be done with the `'` character.
 Print "hello!" 'this line prints hello! on the output console
 Print "hello!" 'this line prints hello! on the output console
 ```
 ```
 
 
+Multiline comments can be made with the `#Rem` preprocessor. See [[language-reference.preprocessor|preprocessor]]
+
 @#### Line breaks in code
 @#### Line breaks in code
 
 
 Lines can currently only be split after ‘[‘, ‘(‘ or ‘,’ tokens.
 Lines can currently only be split after ‘[‘, ‘(‘ or ‘,’ tokens.
@@ -40,3 +42,14 @@ Hexadecimal numbers can be entered using the $ symbol
 ```
 ```
 Local i:=$A0F
 Local i:=$A0F
 ```
 ```
+
+@#### File privacy levels
+
+Privacy levels can be set at file scope:
+
+-`Public` can be accessed from anywhere. It is the default level.
+
+-`Private` can be accessed within the file only.
+
+-`Internal` can be accessed from the same module only.
+

+ 1 - 0
modules/monkey/newdocs/language/modules.md

@@ -63,6 +63,7 @@ This function is called *after* global variables (including global Consts) have
 
 
 Since modules can't have cyclic dependencies, Mains will always execute in the correct order, eg: if module X imports module Y, then module Y's Main is guaranteed to be called before module X's.
 Since modules can't have cyclic dependencies, Mains will always execute in the correct order, eg: if module X imports module Y, then module Y's Main is guaranteed to be called before module X's.
 
 
+You can use the `Internal` keyword at class or file scope to declare module internal accessibility. 
 
 
 @#### Importing modules
 @#### Importing modules
 
 

+ 8 - 11
modules/monkey/newdocs/language/pointers.md

@@ -8,7 +8,7 @@ In Monkey2 pointers are mainly used with external C/C++ code.
 Try not to use pointers unless absolutely necessary. It can lead to bugs if the pointed address is not kept "alive". Pointers to globals are safe, for example.  
 Try not to use pointers unless absolutely necessary. It can lead to bugs if the pointed address is not kept "alive". Pointers to globals are safe, for example.  
 You must have access to the memory you're trying to reach or you'll have a (fatal) memory access violation.
 You must have access to the memory you're trying to reach or you'll have a (fatal) memory access violation.
 
 
-A pointer can point to any kind of type, even garbage collected types. This can lead to bad things too as the garbage collector is not 'aware' of pointers.
+A pointer should not point to a class instance. To get a pointer to your class object, you'll have to cast it to `Void Ptr`. See example below.
 
 
 @#### Declarations
 @#### Declarations
 
 
@@ -49,7 +49,7 @@ Note you can use pointer arythmetics with the index operator(`[]`) but you have
 
 
 @#### Dereferencing with ->
 @#### Dereferencing with ->
 
 
-You can access user defined types fields, methods,.. with the `->` operator. It is equivalent to `[0].`
+You can access a struct fields, methods,.. with the `->` operator. It is equivalent to `[0].`. Note that pointer to class is prohibited.
 
 
 ```
 ```
 Struct str
 Struct str
@@ -72,18 +72,15 @@ You can Cast a pointer and do some explicit conversions with the `Cast` operator
 
 
 `Cast`<_Type_>(_address_)
 `Cast`<_Type_>(_address_)
 
 
-An example with a useless conversion from Int to Void to Int:
+An example with a conversion from Class(reference) to Void Ptr to Class:
 ```
 ```
-Local i:int=1
+Local foo:=New myFooClass()
 Local myVoidPtr:Void Ptr
 Local myVoidPtr:Void Ptr
 
 
-myVoidPtr=Cast<Void Ptr>(VarPtr i)
+myVoidPtr=Cast<Void Ptr>(foo)
 
 
-Local j:int
-Local myIntPtr:Int Ptr
+Local foo2:myFooClass
 
 
-myIntPtr=Cast<Int Ptr>(myVoidPtr)
-j=myIntPtr[0]
+foo2=Cast<myFooClass>(myVoidPtr)
 ```
 ```
-`j` receives the value of `i` but does not have the same address.
-`myIntPtr` and `myVoidPtr` both point to the same address (`VarPtr i`) but have different types.
+"foo" and "foo2" will have the same address(reference). Note that casting to `Void Ptr` is essentially used when dealing with external native code.

+ 2 - 0
modules/monkey/newdocs/language/user-types.md

@@ -215,6 +215,8 @@ There are three levels of encapsulation for class and struct members:
 
 
 -`Private` members can only be accessed by the base class. Code existing in the same source file have acces to `Private` members too.
 -`Private` members can only be accessed by the base class. Code existing in the same source file have acces to `Private` members too.
 
 
+There is also the `Internal` privacy level, used to declare module internal accessibility.
+
 example:
 example:
 ```
 ```
 Class Foo
 Class Foo