I kinda think they aren’t! I think they’re a clean different thing, which is overloading the struct keyword, and maybe that part should change.
- A file is “just a struct”
- But a file can’t be a tuple
- But it can’t be an
externorpackedeither - But tuples don’t take a modifier!
- But it can’t be an
- But a file can’t be a tuple
- We have
@Structcoming up, do we use it to make a tuple?- Nope! We use
@Tuple. So why is its@typeInfoa.@"struct"? Of typeStruct?
- Nope! We use
- Tuples are structurally typed, every
.{ bool, bool }is the same type.- Structs are very much not structurally typed,
Foo{ .a: bool, .b: bool }is not at all aBar{ .a: bool, .b: bool }.
- Structs are very much not structurally typed,
- We can de
structure a tuple, but not astruct, them we just construct. - Tuples have a
.len“field”, structs… I mean they can but, mostly, no.
OK, but we still need to define tuple types, somehow.
If not with struct, how? Keywords are expensive.
How about:
fn tupleator() .{ []const u8, []const u8 } {
return .{ "why", "not?" };
}
This is not ungrammatical, but currently gives the error:
error: type ‘type’ does not support array initialization syntax
Well.
What if it did?