mojo icon indicating copy to clipboard operation
mojo copied to clipboard

[stdlib]: Allow ListLiteral as an initializer to List

Open lsh opened this issue 9 months ago • 1 comments

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]

lsh avatar May 04 '24 17:05 lsh

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

helehex avatar May 04 '24 18:05 helehex

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.

JoeLoser avatar May 09 '24 04:05 JoeLoser

Dang I kinda liked that

helehex avatar May 09 '24 05:05 helehex

could we do a @nonmaterializable struct around pop.array right now?

helehex avatar May 09 '24 06:05 helehex