A Discussion of Tuple Syntax

Meta jared771 at gmail.com
Wed Aug 21 12:01:17 PDT 2013


On Wednesday, 21 August 2013 at 17:40:55 UTC, bearophile wrote:
> f. unpacking small arrays.
>
> auto a = [10, 20];
> const x = a[0];
> const y = a[1];

I don't know if you saw this, but I mentioned in my other post an 
interesting thing you could do if compiler tuples had an 
unpacking syntax. You currently can't use tupleof with array, but 
allowing it would also allow any hypothetical unpacking syntax to 
unpack an array. An example:

int[3] arr = [1, 2, 3];
//a = 1, b = 2, c = 3
auto (a, b, c) = arr.tupleof;





More information about the Digitalmars-d mailing list