Thread overview
Tuple expansion already?
Nov 18, 2015
Ali Çehreli
Nov 18, 2015
rsw0x
Nov 18, 2015
deadalnix
Nov 18, 2015
Jakob Ovrum
Nov 18, 2015
Meta
Nov 18, 2015
Brad Anderson
Nov 18, 2015
thedeemon
November 18, 2015
For once, let's take something from C++. ;) Structured bindings are accepted for C++:

  https://isocpp.org/blog/2015

Assuming that f() returns a tuple,

  auto {x,y,z} = f();

will be the same as

  auto t = f();
  auto x = get<1>(t);
  auto y = get<2>(t);
  auto z = get<3>(t);

Ali
November 18, 2015
On Wednesday, 18 November 2015 at 02:19:34 UTC, Ali Çehreli wrote:
> For once, let's take something from C++. ;) Structured bindings are accepted for C++:
>
>   https://isocpp.org/blog/2015
>
> Assuming that f() returns a tuple,
>
>   auto {x,y,z} = f();
>
> will be the same as
>
>   auto t = f();
>   auto x = get<1>(t);
>   auto y = get<2>(t);
>   auto z = get<3>(t);
>
> Ali

Kenji already wrote(and implemented IIRC) a DIP for this, I don't think it was ever approved.
http://wiki.dlang.org/DIP32

I wish D had better Tuple handling at the language level.
November 18, 2015
On Wednesday, 18 November 2015 at 02:19:34 UTC, Ali Çehreli wrote:
> For once, let's take something from C++. ;) Structured bindings are accepted for C++:
>
>   https://isocpp.org/blog/2015
>
> Assuming that f() returns a tuple,
>
>   auto {x,y,z} = f();
>
> will be the same as
>
>   auto t = f();
>   auto x = get<1>(t);
>   auto y = get<2>(t);
>   auto z = get<3>(t);
>
> Ali

Relevant:

https://github.com/D-Programming-Language/dmd/pull/341

November 18, 2015
On Wednesday, 18 November 2015 at 02:19:34 UTC, Ali Çehreli wrote:
> For once, let's take something from C++. ;) Structured bindings are accepted for C++:
>
>   https://isocpp.org/blog/2015
>
> Assuming that f() returns a tuple,
>
>   auto {x,y,z} = f();
>
> will be the same as
>
>   auto t = f();
>   auto x = get<1>(t);
>   auto y = get<2>(t);
>   auto z = get<3>(t);
>
> Ali

100x yes. Also dedicated tuple syntax and multiple return types like

#(int, string) getTup()
{
    return #(0, "");
}

#(i, s) = getTyp();
writeln("i = ", i, ", s = ", s);
November 18, 2015
On Wednesday, 18 November 2015 at 02:19:34 UTC, Ali Çehreli wrote:
> For once, let's take something from C++. ;) Structured bindings are accepted for C++:
>
>   https://isocpp.org/blog/2015
>
> Assuming that f() returns a tuple,
>
>   auto {x,y,z} = f();
>
> will be the same as
>
>   auto t = f();
>   auto x = get<1>(t);
>   auto y = get<2>(t);
>   auto z = get<3>(t);
>
> Ali

I feel like some of the competitive advantage of D is falling away from us with some of the recent C++ developments like this this. Stackless resumable functions is another thing that comes to mind. As does the Core Guidelines Support Library/static analysis pair (though I suspect it'll never be quite as foolproof as Safe D).

We can't even do the equivalent of std::tie[1] in D as a workaround for tuple expansion because there are no ref typed Tuples (unless something changed from when I last looked).

http://en.cppreference.com/w/cpp/utility/tuple/tie
November 18, 2015
On Wednesday, 18 November 2015 at 02:21:04 UTC, rsw0x wrote:
> On Wednesday, 18 November 2015 at 02:19:34 UTC, Ali Çehreli wrote:
>> For once, let's take something from C++. ;) Structured bindings are accepted for C++:
>>
>>   https://isocpp.org/blog/2015
>>
>> Assuming that f() returns a tuple,
>>
>>   auto {x,y,z} = f();
>>
>> will be the same as
>>
>>   auto t = f();
>>   auto x = get<1>(t);
>>   auto y = get<2>(t);
>>   auto z = get<3>(t);
>>
>> Ali
>
> Kenji already wrote(and implemented IIRC) a DIP for this, I don't think it was ever approved.
> http://wiki.dlang.org/DIP32
>
> I wish D had better Tuple handling at the language level.

I wish as well, but we have a lot on the drawing board right now, I don'tt hink this is the time for that.

There have been proposal that are better than Kenji. Grammatically, Kenji's proposal have some serious problems, { is already the start of a delegate, a block statement, a struct literal, and I'm not sure what else, but too much.

November 18, 2015
On Wednesday, 18 November 2015 at 04:31:08 UTC, Brad Anderson wrote:

> We can't even do the equivalent of std::tie[1] in D as a workaround for tuple expansion because there are no ref typed Tuples (unless something changed from when I last looked).

Several implementations here:
http://forum.dlang.org/thread/ubrngkdmyduepmfkhefp@forum.dlang.org