[stdlib] Use VariadicPack instead of VariadicList where possible#6369
[stdlib] Use VariadicPack instead of VariadicList where possible#6369martinvuyk wants to merge 1 commit intomodular:mainfrom
VariadicPack instead of VariadicList where possible#6369Conversation
d59c519 to
61406e5
Compare
Signed-off-by: martinvuyk <martin.vuyklop@gmail.com>
61406e5 to
f5b7b8b
Compare
|
Blocked by #6381 |
|
I'd like to see a more detailed motivation for this change. |
| def __init__(out self, var *elems: Self.ElementType, __list_literal__: ()): | ||
| def __init__[ | ||
| *Ts: type_of(Self.ElementType) | ||
| ](out self, var *elems: *Ts, __list_literal__: ()) where ( |
There was a problem hiding this comment.
This is almost certainly not correct. An InlineArray takes a homogenous type.
There was a problem hiding this comment.
it does, as an example *Ts: type_of(Int) enforces a single type
There was a problem hiding this comment.
If the goal is to try and optimize InlineArray using this information, I think the better solution is to have __list_literal__ carry an actual size parameter, but I can be convinced otherwise.
There was a problem hiding this comment.
It's not about optimization but enforcing a compile-time known constraint at compile time
| # FIXME: this used to be simpler | ||
| # var vb = Int(to_int(b)) | ||
| var vb = RuntimeTuple[IntTuple(UNKNOWN_VALUE)](Int(b)) | ||
| comptime R = RuntimeTuple[IntTuple(UNKNOWN_VALUE)] |
There was a problem hiding this comment.
I'm strongly -1 on these single letter aliases.
| def __init__[ | ||
| *Ts: type_of(String) | ||
| ]( | ||
| out self: InlineArray[StaticString, Self.size], |
There was a problem hiding this comment.
We're moving away from custom Self types in favor of where clauses, so this is not ideal.
There was a problem hiding this comment.
yeah I don't know what is going on with the compiler but it eagerly lowers StringLiteral into String so anything wanting to construct InlineArray[StaticString, 1] = ["asd"] where the constructor expects the initializer type to equal the target type it would fail. We currently don't have a nice way for variadic packs to properly take implicit type conversion into account (#6357) and also carries type information incorrectly (#6381)
Use
VariadicPackinstead ofVariadicListwhere possible. #6356 remains blocked in another PR, these here should work with no issues