Open thosakwe opened 6 years ago
Note: Arrays are primitives, and not generic.
An array literal could also just set notation. This might make parsing logic a little more difficult, but it's still doable:
fn intArray: Int[] => {2, 3, 4}
fn spreadArray(a: Int[]) => {...a, 5, 6}
The problem with that is, how would you declare an array of known size?
Currently: var otherArr = [Int:255]
.
However, this conflicts with set notation {}
.
{Int: 255}
is also an object literal.
One option is reserving an Array
keyword?
var arr = Array {Int:255}
Not sure how attractive that is.
Array<Int:255>
is also a bit odd.
In C++, you can say new int[255]
.
In Bonobo?
Maybe new Int[255]
.
Not very consistent with {}
.
Array Int[255]
?
Our current consensus:
type FiveInts = Int[5]
Arrays are technically anonymous (though the analyzer can easily compare them), and have a fixed size, known both to the user and the compiler. They are not generic.
Collections, though, would be class-based, and generic.