Tuple DIP
MrSmith
mrsmith33 at yandex.ru
Sat Jan 13 22:54:05 UTC 2018
On Saturday, 13 January 2018 at 21:05:27 UTC, Timon Gehr wrote:
> On 13.01.2018 21:49, Timon Gehr wrote:
>>
>>> auto (name, email) = fetchUser();
>>> vs
>>> auto {name, email} = fetchUser();
>>>
>
> BTW: What do you think each of those do?
> I'd expect the following:
>
> ---
> auto (name, email) = fetchUser();
> =>
> auto __tmp = fetchUser();
> auto name = __tmp[0], email = __tmp[1];
> ---
>
> ---
> auto {name, email} = fetchUser();
> =>
> auto __tmp = fetchUser();
> auto name = __tmp.name, email = __tmp.email;
> ---
>
> The DIP proposes only the first one of those features, and only
> for AliasSeq's or types that alias this to an AliasSeq (such as
> tuples).
How about this syntax for getting a tuple of fields:
---
auto (name, email) = fetchUser().(name, email);
---
More information about the Digitalmars-d
mailing list