make generics worse

This commit is contained in:
nora 2023-12-15 18:20:52 +01:00
parent 1a0828bd32
commit 5fefc46402
7 changed files with 107 additions and 73 deletions

View file

@ -1,21 +1,21 @@
type List[T] = struct {
ptr: Int,
len: Int,
cap: Int,
};
function new(): List[Int] = (
List { ptr: 0, len: 0, cap: 0 }
);
function push(list: List[Int], elem: Int) = (
growIfNeeded(list, 1);
);
//type List[T] = struct {
// ptr: Int,
// len: Int,
// cap: Int,
//};
//
//function new(): List[Int] = (
// List { ptr: 0, len: 0, cap: 0 }
//);
//
//function push(list: List[Int], elem: Int) = (
// growIfNeeded(list, 1);
//);
//
// PRIVATE:
function growIfNeeded(list: List[Int], elems: Int) = (
if (list.len + elems) < list.cap then (
let newMemory = std.rt.alloc.allocateItem(0_I32, 0_I32);
);
);
//
//function growIfNeeded(list: List[Int], elems: Int) = (
// if (list.len + elems) < list.cap then (
// let newMemory = std.rt.alloc.allocateItem(0_I32, 0_I32);
// );
//);