Thanks... that was very helpful.
I played around with the following playground. I think I understand it. Now to integrate into production code. proc createUncheckedArray(n: int): ptr UncheckedArray[int] = cast[ptr UncheckedArray[int]](cast[pointer](alloc(n * sizeof(int)))) # Syntactic sugar template withLength(elements: untyped, length: int): untyped = toOpenArray(elements, 0, length - 1) when isMainModule: import algorithm # Simple assertion check template shouldBe[T](elements: untyped, answer: openArray[T]): untyped = assert (elements.withLength length) == answer proc init_0_to_n(elements: var openArray[int]) = for i in 0 .. elements.high: elements[i] = i + 1 proc double(elements: var openArray[int]) = for i in 0 .. elements.high: elements[i] *= 2 const length = 4 var elements = createUncheckedArray length # Populate the UncheckedArray init_0_to_n(elements.withLength length) elements.shouldBe [1, 2, 3, 4] double elements.withLength length elements.shouldBe [2, 4, 6, 8] # Descending sort (elements.withLength length).sort do (a, b: int) -> int: b.cmp a elements.shouldBe [8, 6, 4, 2] dealloc elements Run