Browse Source

update documentation

Vladislav Folts 10 years ago
parent
commit
1176d3ea26
1 changed files with 15 additions and 10 deletions
  1. 15 10
      doc/wiki/eberon-dynamic-arrays.md

+ 15 - 10
doc/wiki/eberon-dynamic-arrays.md

@@ -1,32 +1,35 @@
-Dynamic arrays are introduced because oberon has no option for dynamically grown sequences except linked lists (and linked lists are not efficient comparing to arrays in some cases).
+Dynamic arrays are similar to static arrays but their length can be changed at runtime - new elements can be added or removed.
 
 ### Syntax
-Dynamic arrays are declared in the same way as oberon arrays - 'dynamic' dimension is marked with '*':
+Dynamic arrays are declared in the same way as static arrays - 'dynamic' dimension is marked with '*':
     
     a1: ARRAY * OF INTEGER;
     a2: ARRAY *, * OF BOOLEAN;
     a3: ARRAY *, 10, * OF CHAR;
 
 ### Semantics
-Dynamic arrays are similar to static arrays but their length can be changed at runtime. Initial length is 0. To add a new element *add* method is used:
+Initial length of dynamic array is 0.
+To add a new element *add* method is used:
 
     array.add(value);
 
-Added *value* type should be compatible with the array elements type. 
+Added _value_ type should be compatible with the array elements type. 
 To remove element from array *remove* method is used:
 
     array.remove(index);
 
-INTEGER *index* specifies element index to remove.
+INTEGER _index_ specifies element index to remove.
 Method *clear* is used to remove all elements from array:
 
     array.clear();
 
 Dynamic arrays also have [[indexOf|eberon-array-methods]] method (similar to static arrays).
 
-Dynamic array can be passed as open array to procedure.
-Procedure cannot have dynamic array as non-VAR parameter.
-Procedure can have dynamic array as a result - in this case a copy of array is returned.
+* Dynamic array can be passed as open array to procedure.
+* Procedure can have dynamic array as VAR parameter and change content of passed array. But dynamic array cannot be passed as non-VAR paramater - ordinary open array should be used.
+* Procedure can have dynamic array as a result - in this case a copy of array is returned.
+
+Example:
 
     MODULE Test;
     TYPE
@@ -48,5 +51,7 @@ Procedure can have dynamic array as a result - in this case a copy of array is r
         ASSERT(a2[0] = 3); (*array was copied, a1 and a2 do not share elements*)
     END Test.
 
-Dynamic array can be assigned to open, static or another dynamic array but not vice versa. Element types should be compatible in this case.
-Dynamic array cannot be assigned to NIL.
+* Dynamic array can be assigned to another dynamic array - destination array content is replaced by the content of source array, lenght became the same as the length of source array.
+* Dynamic array can be assigned to open or static array but not vice versa.
+* Element types should be compatible for all array assignment operations.
+* Dynamic array cannot be assigned to NIL.