Example of Dependent Types?


Say you have 3 objects, a global MemoryStore, which has an array of MemorySlabCache objects, and each MemorySlabCache has an array of MemorySlab objects. Sort of like this:

class MemoryStore {   caches: Array<MemorySlabCache> = [] }  class MemorySlabCache {   size: Integer   slabs: Array<MemorySlab> = [] }  class MemorySlab {    } 

But the thing is, this doesn’t capture everything. It also needs to capture the fact that each MemorySlabCache has a size, which is used to tell what size the MemorySlab objects are it contains. So it’s more like this:

class MemoryStore {   caches: Array<MemorySlabCache> = [] }  class MemorySlabCache {   size: Integer   slabs: Array<MemorySlab<size>> = [] }  class MemorySlab<size: Integer> {    } 

Then we create our caches:

let 4bytes = new MemorySlabCache(size: 4) let 8bytes = new MemorySlabCache(size: 8) ... let 32bytes = new MemorySlabCache(size: 32) ... store.caches.push(4bytes, 8bytes, ..., 32bytes, ...) 

Does this count as a "dependent type", "a type whose definition depends on a value"? Since the type of the Array<MemorySlab<size>> is dependent on the value assigned to the size field on MemorySlabCache. If not, what is this? What would make it into an example of dependent types?