A different tuple syntax

deadalnix deadalnix at gmail.com
Thu May 30 21:49:40 PDT 2013


On Friday, 31 May 2013 at 03:07:22 UTC, nazriel wrote:
> That actually looks good...
> I liked idea of:
>
>     auto (x, y) = foo();
>     (int x1, string y1) = foo();
>
>     (int, string) foo() {
>
>          (int tmp, string tmp2) = (3, "dsa");
>
>          return (42, "dsa");
>     }
>
> but it was shoot down because of various issues.
>

This have an issue with one element tuple. Not unsolvable, but 
must be considered.

> Then proposal with {} risen:
>
>     auto {x, y} = foo();
>     {int x1, string y1} = foo();
>
>     {int, string} foo() {
>
>         {int tmp, string tmp2} = {3, "dsa"};
>
>         return {42, "dsa"};
>     }
>

This is a reciepe for disaster. {} are already used way too much, 
sometime on way that are hard to deambiguate.

>
> Now this:
>
>     auto #(x, y) = foo();
>     #(int x1, string y1) = foo();
>
>     #(int, string) foo() {
>
>         #(int tmp, string tmp2) = #(3, "dsa");
>
>         return #(42, "dsa");
>     }
>

This have the advantage of not having issue with one element 
tuples.

> My 2 cents :))
>
> bearophile what do you think?

I also do agree that the 3rd one is probably the best.


More information about the Digitalmars-d mailing list