January 13
On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote:
> As promised [1], I have started setting up a DIP to improve
+1, please.
January 13
On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote:
> As promised [1], I have started setting up a DIP to improve tuple ergonomics in D:
> [snip]

I'm glad you're working on this.

Proposal 1 is a little terse in explaining what you mean by unpacking AliasSeqs. You might explain it in a little more detail.

Also, Proposal 1 starts with this example
auto (a, b) = tuple(1, "2");
(int a, string b) = tuple(1, "2");
but it also looks natural to be able to write
(int, string) (a, b) = tuple(1, "2");
it looks from some of the other proposals that if they combine together then this would also work.

Proposal 3 could use an example with named tuples.

In proposal 6, how does
auto (a, _) = t;
expand for multiple? Would you be forced to do
auto (a, _, _, _, _, _) = t;
if the tuple has 6 entries?
January 13
On Saturday, 13 January 2018 at 02:08:03 UTC, jmh530 wrote:
> On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote:
>> As promised [1], I have started setting up a DIP to improve tuple ergonomics in D:
>> [snip]
>
> I'm glad you're working on this.
>
> Proposal 1 is a little terse in explaining what you mean by unpacking AliasSeqs. You might explain it in a little more detail.
>
> Also, Proposal 1 starts with this example
> auto (a, b) = tuple(1, "2");
> (int a, string b) = tuple(1, "2");
> but it also looks natural to be able to write
> (int, string) (a, b) = tuple(1, "2");

Really ?
After the type should be the declarator. In this example there's no declarator but if you add it then it becomes very strange:

(int, string) ab (a, b) = tuple(1, "2");


January 13
On Saturday, 13 January 2018 at 02:15:37 UTC, Basile B. wrote:
> On Saturday, 13 January 2018 at 02:08:03 UTC, jmh530 wrote:
>> On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote:
>>> As promised [1], I have started setting up a DIP to improve tuple ergonomics in D:
>>> [snip]
>>
>> I'm glad you're working on this.
>>
>> Proposal 1 is a little terse in explaining what you mean by unpacking AliasSeqs. You might explain it in a little more detail.
>>
>> Also, Proposal 1 starts with this example
>> auto (a, b) = tuple(1, "2");
>> (int a, string b) = tuple(1, "2");
>> but it also looks natural to be able to write
>> (int, string) (a, b) = tuple(1, "2");
>
> Really ?
> After the type should be the declarator. In this example there's no declarator but if you add it then it becomes very strange:
>
> (int, string) ab (a, b) = tuple(1, "2");

Forgot to say that on the other hand

  (int a, string b) ab = tuple(1, "2");

works better.
January 13
On Saturday, 13 January 2018 at 02:18:20 UTC, Basile B. wrote:
> On Saturday, 13 January 2018 at 02:15:37 UTC, Basile B. wrote:
>> On Saturday, 13 January 2018 at 02:08:03 UTC, jmh530 wrote:
>>> [...]
>>
>> Really ?
>> After the type should be the declarator. In this example there's no declarator but if you add it then it becomes very strange:
>>
>> (int, string) ab (a, b) = tuple(1, "2");
>
> Forgot to say that on the other hand
>
>   (int a, string b) ab = tuple(1, "2");
>
> works better.

Better check twice than one. Actually i see now that there's no Declarator as used here, i.e for the whole tuple. Curious.
January 13
On Saturday, 13 January 2018 at 02:15:37 UTC, Basile B. wrote:
> On Saturday, 13 January 2018 at 02:08:03 UTC, jmh530 wrote:
>> [snip]
>> Also, Proposal 1 starts with this example
>> auto (a, b) = tuple(1, "2");
>> (int a, string b) = tuple(1, "2");
>> but it also looks natural to be able to write
>> (int, string) (a, b) = tuple(1, "2");
>
> Really ?
> After the type should be the declarator. In this example there's no declarator but if you add it then it becomes very strange:
>
> (int, string) ab (a, b) = tuple(1, "2");

I left out a word there...I had meant that it would be natural to replace the auto version with that version. I would think it would work in combination with Proposal 3.

If
auto (a, b) = tuple(1, "2");
works, then surely
__Tuple!(int, string) (a, b) = tuple(1, "2");
should work, which is equivalent to
(int, string) (a, b) = tuple(1, "2");

January 13
On Saturday, 13 January 2018 at 00:51:51 UTC, Timon Gehr wrote:
> On 13.01.2018 01:20, Mark wrote:
>> int (x,y) = f(1, 2); // x=3, y=-1
>> int (w,z) = (1, 2).f() // same as above, UFCS
>> int (u,v) = (1, 2).(sum, diff) // same as above, "lambda tuple"
>> 
>> In the last example, (sum, diff) is basically lowered to (x,y) => (sum(x,y), diff(x,y)).
>
> I think this is easy enough to achieve without dedicated syntax:
>
> import std.typecons;
>
> template apply(F...){
>     auto apply(T)(T arg){
>         import std.conv, std.range, std.algorithm;
>         return mixin(text("(",iota(F.length).map!(i=>text("F[",i,"](arg)")).join(","),")"));
>     }
> }
>
> void main(){
>     int sum(int a, int b) { return a+b; }
>     int diff(int a, int b) { return a-b; }
>     auto (u,v)=(1,2).apply!(sum, diff);
>     import std.stdio;
>     writeln(u," ",v);
> }

I didn't think of that. That's cool! :)
January 13
On 2018-01-12 23:44, Timon Gehr wrote:
> As promised [1], I have started setting up a DIP to improve tuple ergonomics in D:

Perhaps I don't have enough knowledge about the existing different types of tuples but Proposal 1 [1] says:

"We add the following syntactic sugar to unpack AliasSeq's"

But the example doesn't contain a single "AliasSeq", only "tuple".

[1] https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md#proposal-1-unpacking-declarations

-- 
/Jacob Carlborg
January 13
On Saturday, 13 January 2018 at 00:37:48 UTC, Chris M. wrote:
> On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote:
>> As promised [1], I have started setting up a DIP to improve tuple ergonomics in D:
>>
>> [...]
>
> Yes please

Very much agree.
January 13
On 13.01.2018 03:08, jmh530 wrote:
> On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote:
>> As promised [1], I have started setting up a DIP to improve tuple ergonomics in D:
>> [snip]
> 
> I'm glad you're working on this.
> 
> Proposal 1 is a little terse in explaining what you mean by unpacking AliasSeqs. You might explain it in a little more detail.
> ...

Will do. std.typecons.Tuple is a slightly more fancy version of the following:

struct Tuple(T...){
    T expand; // AliasSeq
    alias expand this; // inherits indexing/slicing etc.
    // with the proposal, also inherits unpacking
}


> Also, Proposal 1 starts with this example
> auto (a, b) = tuple(1, "2");
> (int a, string b) = tuple(1, "2");
> but it also looks natural to be able to write
> (int, string) (a, b) = tuple(1, "2");
> it looks from some of the other proposals that if they combine together then this would also work.
> ...

Well, "auto" is not a placeholder type, but I'll think about it.

> Proposal 3 could use an example with named tuples.
> 
> In proposal 6, how does
> auto (a, _) = t;
> expand for multiple? Would you be forced to do
> auto (a, _, _, _, _, _) = t;
> if the tuple has 6 entries?

Yes and no. I'd imagine one would use

auto a = t[0];
1 2 3 4 5 6 7 8 9