A different tuple syntax

Diggory diggsey at googlemail.com
Thu May 30 14:48:00 PDT 2013


On Thursday, 30 May 2013 at 21:40:47 UTC, js.mdnq wrote:
> On Thursday, 30 May 2013 at 12:32:46 UTC, bearophile wrote:
>> If you don't like to introduce a new keyword, then a different 
>> alternative is to use the @ again, a bit like UDAs:
>>
>> @{...}
>>
>> @[10] @{int, string} tup = @{1, "hi"}; // With UDA.
>> foreach (Float; @{float, double, real}) { ... }
>> auto @{x, y} = @{1, "hi"};
>> @{auto x, y} = @{1, "hi"};
>> @{int x, string y} = @{1, "hi"};
>> foreach (i, const @{x, y}; [@{1,2}, @{3,4}, @{5,6}, ...]) {
>> void foo(@{int, string name}, string msg);
>> (@{A a, B b}) => a + b;
>> switch (tup) { case @{1, 2}: ... }
>>
>> Bye,
>> bearophile
>
> Or rather # or & as they do have some inherent relation to 
> tuples..
>
> #(int, string) tup
> &(int, string) tup
>
> The second remind one it is a sort of concatenation of types. 
> e.g., int & string.

# would not be bad, but not & as that would just be confusing...


More information about the Digitalmars-d mailing list