[Feature] Implement Array<T>
type and constant array initialisation expression syntax
#499
Open
2 of 8 tasks
Is there an existing proposal for this?
This feature does not exist in the latest version
Proposal
Implement the
Array<T>
type based on the givenArray
type from the target languages JavaScript and TypeScript (Ref:Array
on MDN), which should allow the dynamic storing of data based on a generic typeT
specififying the type constraint of an Array.This issue also includes implementing the following array syntax:
This also includes providing the basic functionality from the prototype
Array
, which includes for now these functions:Array<T>.concat(otherArray: Array<T>) -> Array<T>
: Joins together the existing array and theotherArray
(in that order), and creates a new shallow copy of both arrays.Array<T>.join(seperator: str) -> str
: Joins together all values of the array by adding the seperator in-between all of them.Array<T>.flat() -> FlatArray<Array<T>>
: Flats the map and resolves all values of any nested arrays and inserts them at the top level of the array.Array<T>.shift() -> T
: Returns the first element of the array and removes it from the object.Array<T>.pop() -> T
: Returns the last element of the array and removes it from the object.Array<T>.reverse() -> Array<T>
: Reverses the original array and returns a reference to it.Array<T>.push(elem: T) -> num
: Pushes a new value to the end of the array and returns the number of elements now in the array.Array<T>.slice(start?: num, start?: end) -> T
: Returns a shallow copy from the given range, start is inclusive, end is exclusive.Exact behaviour / changes you want
Array<T>
and proper handling for the generic typing. ([Feature] Implement basic generic type system for built-in types #494)Array
constructor and allow it to be referenced in Kipper code, so type checks usingtypeof(val) == Array
should be possible.Array
prototype and all given functions.The text was updated successfully, but these errors were encountered: