Open andrewrk opened 1 year ago
What's the use case behind this? Why would one opt for the builtins when we can already do foo = bar
and foo = .{ 12, 14 }
, bar = .{0} ** bar.len
?
Same as the reason that @memcpy
supports both src and dest being an array, even though it is equivalent to dest.* = src.*
. The reason being language consistency.
To implement this reasonably, as well as for more general consistency between arrays and tuples, Zig should define homogeneous tuples (by which I mean tuples whose fields all have the same type) as having the same memory layout as arrays (i.e. fields laid out contiguously in memory with no extra padding). Is this something which the (theoretical) spec already guarantees? (As far as I know the implementation does, although I haven't checked.)
Extracted from #15278.
This test should pass:
Instead, this happens: