Changeset 5485bcac


Ignore:
Timestamp:
Oct 30, 2024, 4:41:30 PM (14 hours ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
292d6cf6
Parents:
a3bd827
Message:

Updated tuple proposal to include array interations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/proposals/tuples.md

    ra3bd827 r5485bcac  
    240240allow restructuring when the type is passed as a type value. This may be
    241241the most correct form, but seems surprising compared to the common use.
     242
     243### Tuple Arrays Not Supported
     244
     245You cannot make an array of tuples. For some reason the type just will not
     246work. Thoretically it could, each tuple type has a size and alignment and
     247could be put in an array. However the following type is not accepted:
     248
     249        [int, char] array[3] = {{1, 'a'}, {2, 'b'}, {3, 'c'}};
     250
     251Now the opposite, a tuple containing an array, does actually work:
     252
     253        [int[3], char] data = {{1, 2, 3}, 'd'};
    242254
    243255### Unary Tuple Value Syntax
     
    539551        ([int, int, int])tuple_int_int;
    540552        ([long, [float, int]])tuple_long_float_int;
     553
     554### Tuple Array Support
     555
     556Arrays of unstructured tuples/packs are not actually required, an array of
     557structures will store the data just as well and this is not the transient
     558context where the unlabeled tuples work well. So it would work fine to
     559not allow an array of packs, but if we do not a better error should be
     560created.
     561
     562All that being said, the following could just work.
     563
     564        [int, char] u_array[3] = {...};
     565
     566What should definitely work is an array of struct tuple, because that should
     567work where a generic structure could be used. This is also part of why arrays
     568of packs are not needed.
     569
     570        tuple([int, char]) s_array[3] = {...};
    541571
    542572### New Tuple Literal Syntax
Note: See TracChangeset for help on using the changeset viewer.