mojo
mojo copied to clipboard
[stdlib]: Allow ListLiteral as an initializer to List
The goal of this PR is to make ListLiteral
useful in a layout independent way. With this design, it should be possible to e.g. change ListLiteral to be:
struct ListLiteral[T: CollectionElement, inferred size: Int]:
var data: InlineArray[T, size]
i remember doing this for some of my internal collections, and something about the AnyRegType stuff going on meant that i ended up removing it for now, but i dont remember exactly what
This is super exciting, but I'd recommend we hold off right this moment on it. I talked with @Mogball about this the other day.
Rationale: ListLiteral
is currently homogenous in the elements it accepts, but it's backed by a Tuple
which supports heterogeneous elements. This representation will change soon — likely to a pop.array
for constraining the element types in ListLiteral
to be homogenous. Given this layout change, I'd rather not have people start depending on this sort of thing as it will lead to surprises and adding users that we're not ready for quite yet.
Dang I kinda liked that
could we do a @nonmaterializable
struct around pop.array
right now?