jinko
jinko copied to clipboard
Add Vector/Array type
So we have to consider a few things here, for example instanciation. How do we instanciate a vector with any number of elements without entirely changing the language? Should we start implementing macros? Should it be a JkInst? Should we add a specifier to the function declaration to mark it as variadic?
The Vector type could be responsible for the low level plumbing and allocate memory itself. We could have the following allocating API:
type pointer; // builtin
// or
type Pointer(raw_addr: int);
ext func allocate(size: int) -> pointer;
ext func reallocate(ptr: pointer) -> pointer;
ext func deallocate(ptr: pointer);
ext func unsafe_write[T](ptr: pointer, value: T);
ext func unsafe_read[T](ptr: pointer) -> T;
We could then, upon dropping a pointer, free it in the garbage collector