Add default values for some primitive type attributes.
[nit.git] / lib / standard / array.nit
index ae227ec..78beeb3 100644 (file)
@@ -23,7 +23,7 @@ special IndexedCollection[E]
        meth enlarge(cap: Int) is abstract
 
        # The current length
-       redef readable attr _length: Int
+       redef readable attr _length: Int = 0
        
        redef meth is_empty do return _length == 0
 
@@ -261,7 +261,7 @@ special ArrayCapable[E]
        end
 
        # Create an array with some `items'.
-       init with(objects: E...)
+       init with_items(objects: E...)
        do
                _items = objects._items
                _capacity = objects._capacity
@@ -301,10 +301,10 @@ special ArrayCapable[E]
        end
 
        # The internal storage.
-       attr _items: NativeArray[E]
+       attr _items: NativeArray[E] = null
 
        # The size of `_items'.
-       attr _capacity: Int
+       attr _capacity: Int = 0
 end
 
 # An `Iterator' on `AbstractArray'
@@ -325,7 +325,7 @@ special IndexedIterator[E]
                _index = 0
        end
 
-       redef readable attr _index: Int
+       redef readable attr _index: Int = 0
        attr _array: AbstractArray[E]
 end
 
@@ -510,7 +510,7 @@ special CoupleMap[K, E]
        end
 
        # The last positive result given by a index(1) call
-       attr _last_index: Int
+       attr _last_index: Int = 0
        
        # Where is the `key' in `_item'?
        # return -1 if not found
@@ -563,13 +563,13 @@ end
 # Native classes ##############################################################
 
 # Subclasses of this class can create native arrays
-class ArrayCapable[E]
+interface ArrayCapable[E]
        # Get a new array of `size' elements.
        protected meth calloc_array(size: Int): NativeArray[E] is intern
 end
 
 # Native C array (void ...).
-class NativeArray[E]
+universal NativeArray[E]
        meth [](index: Int): E is intern
        meth []=(index: Int, item: E) is intern
        meth copy_to(dest: NativeArray[E], length: Int) is intern