Jump to page: 1 2
Thread overview
C# 7 Features - Tuples
Aug 25, 2016
dom
Aug 25, 2016
Suliman
Aug 25, 2016
Seb
Aug 25, 2016
jmh530
Aug 25, 2016
rumbu
Aug 25, 2016
Timon Gehr
Aug 26, 2016
Kagamin
Aug 26, 2016
Cauterite
Sep 05, 2016
Nick Treleaven
Sep 05, 2016
Lodovico Giaretta
Sep 06, 2016
Nick Treleaven
Aug 26, 2016
ixid
August 25, 2016
https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/

came across the new c# features today. I really liked the syntax for Tuples (and deconstructors), would be great to have a similar syntax in D :)


August 25, 2016
On Thursday, 25 August 2016 at 13:41:29 UTC, dom wrote:
> https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/
>
> came across the new c# features today. I really liked the syntax for Tuples (and deconstructors), would be great to have a similar syntax in D :)

Yeah, it's looks very cool!
August 25, 2016
On Thursday, 25 August 2016 at 13:41:29 UTC, dom wrote:
> https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/
>
> came across the new c# features today. I really liked the syntax for Tuples (and deconstructors), would be great to have a similar syntax in D :)

Pretty obvious syntax, but would require the comma operator to be removed. Isn't it deprecated long enough meanwhile, so we finally can kill it?

But I dislike the named tuple members.
Why not declare them at the calling site?

(int, int, int, string) fn()
{
   return (3, 2, 1, "meins");
}

int x, y, z;
string s;
(x, y, z, s) = fn();
August 25, 2016
On 8/25/16 10:43 AM, Dominikus Dittes Scherkl wrote:
> On Thursday, 25 August 2016 at 13:41:29 UTC, dom wrote:
>> https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/
>>
>>
>> came across the new c# features today. I really liked the syntax for
>> Tuples (and deconstructors), would be great to have a similar syntax
>> in D :)
>
> Pretty obvious syntax, but would require the comma operator to be
> removed. Isn't it deprecated long enough meanwhile, so we finally can
> kill it?

It was *just* deprecated, I don't think even in a released version yet!

-Steve
August 25, 2016
On Thursday, 25 August 2016 at 15:02:06 UTC, Steven Schveighoffer wrote:
> On 8/25/16 10:43 AM, Dominikus Dittes Scherkl wrote:
>> On Thursday, 25 August 2016 at 13:41:29 UTC, dom wrote:
>>> https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/
>>>
>>>
>>> came across the new c# features today. I really liked the syntax for
>>> Tuples (and deconstructors), would be great to have a similar syntax
>>> in D :)
>>
>> Pretty obvious syntax, but would require the comma operator to be
>> removed. Isn't it deprecated long enough meanwhile, so we finally can
>> kill it?
>
> It was *just* deprecated, I don't think even in a released version yet!
>
> -Steve

Yep,

https://dlang.org/deprecate.html#Using%20the%20result%20of%20a%20comma%20expression
https://github.com/dlang/dmd/pull/5737

However working out the rules and changes for a Tuple syntax would be a great topic for a DIP:

https://github.com/dlang/DIPs

Btw there has been previous work on this topic, so this could be used as a base:

https://wiki.dlang.org/DIP32
August 25, 2016
On Thursday, 25 August 2016 at 15:50:09 UTC, Seb wrote:
>
> https://dlang.org/deprecate.html#Using%20the%20result%20of%20a%20comma%20expression
> https://github.com/dlang/dmd/pull/5737
>
> However working out the rules and changes for a Tuple syntax would be a great topic for a DIP:
>
> https://github.com/dlang/DIPs
>
> Btw there has been previous work on this topic, so this could be used as a base:
>
> https://wiki.dlang.org/DIP32

I like DIP32, but I wouldn't be that bothered if it took until 2018 to get something like it in D.
August 25, 2016
On Thursday, 25 August 2016 at 14:43:35 UTC, Dominikus Dittes Scherkl wrote:

>
> But I dislike the named tuple members.
> Why not declare them at the calling site?
>
> (int, int, int, string) fn()
> {
>    return (3, 2, 1, "meins");
> }
>
> int x, y, z;
> string s;
> (x, y, z, s) = fn();

This is possible:

"
(string, string, string) LookupName(long id) // tuple return type
{
    ... // retrieve first, middle and last from data storage
    return (first, middle, last); // tuple literal
}

...

"You can also deconstruct into existing variables with a deconstructing assignment:

(first, middle, last) = LookupName(id2); // deconstructing assignment"
August 25, 2016
On 25.08.2016 16:43, Dominikus Dittes Scherkl wrote:
> On Thursday, 25 August 2016 at 13:41:29 UTC, dom wrote:
>> https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/
>>
>>
>> came across the new c# features today. I really liked the syntax for
>> Tuples (and deconstructors), would be great to have a similar syntax
>> in D :)
>
> Pretty obvious syntax, but would require the comma operator to be
> removed. Isn't it deprecated long enough meanwhile, so we finally can
> kill it?
>
> But I dislike the named tuple members.
> Why not declare them at the calling site?
>
> (int, int, int, string) fn()
> {
>    return (3, 2, 1, "meins");
> }
>
> int x, y, z;
> string s;
> (x, y, z, s) = fn();

I don't understand. What is the issue here?
August 26, 2016
On Thursday, 25 August 2016 at 14:43:35 UTC, Dominikus Dittes Scherkl wrote:
> (int, int, int, string) fn()
> {
>    return (3, 2, 1, "meins");
> }
>
> int x, y, z;
> string s;
> (x, y, z, s) = fn();

See https://forum.dlang.org/post/ubrngkdmyduepmfkhefp@forum.dlang.org
August 26, 2016
On Thursday, 25 August 2016 at 13:41:29 UTC, dom wrote:
> https://blogs.msdn.microsoft.com/dotnet/2016/08/24/whats-new-in-csharp-7-0/
>
> came across the new c# features today. I really liked the syntax for Tuples (and deconstructors), would be great to have a similar syntax in D :)

This is fantastic, hopefully we can have this syntax in D.Ultimately it would be nice if we could move towards the rest of the C-style tidy ups that are becoming more commonly used but I know this community is pretty conservative. Optional semi-colons, no parens on if, while etc and enforced curly braces. Also := being a synonym for auto assignment.
« First   ‹ Prev
1 2