Re: Tuple DIP

2018-09-21 Thread 12345swordy via Digitalmars-d
On Wednesday, 19 September 2018 at 21:48:40 UTC, Timon Gehr wrote: On 19.09.2018 23:14, 12345swordy wrote: On Tuesday, 3 July 2018 at 16:11:05 UTC, 12345swordy wrote: On Thursday, 28 June 2018 at 13:24:11 UTC, Timon Gehr wrote: [...] Is there any way we can help on this? *Bump* I want

Re: Tuple DIP

2018-09-20 Thread Guillaume Boucher via Digitalmars-d
On Saturday, 13 January 2018 at 18:28:55 UTC, Timon Gehr wrote: However, this proposal is independent of all the other ones, so in the end it is up to Walter and Andrei. Have there been any discussions regarding the semantics of _? struct G { ~this() { writeln("destruct"); } } void main() {

Re: Tuple DIP

2018-09-19 Thread Timon Gehr via Digitalmars-d
On 19.09.2018 23:14, 12345swordy wrote: On Tuesday, 3 July 2018 at 16:11:05 UTC, 12345swordy wrote: On Thursday, 28 June 2018 at 13:24:11 UTC, Timon Gehr wrote: On 26.06.2018 11:55, Francesco Mecca wrote: On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote: As promised [1], I have

Re: Tuple DIP

2018-09-19 Thread 12345swordy via Digitalmars-d
On Tuesday, 3 July 2018 at 16:11:05 UTC, 12345swordy wrote: On Thursday, 28 June 2018 at 13:24:11 UTC, Timon Gehr wrote: On 26.06.2018 11:55, Francesco Mecca 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

Re: Tuple DIP

2018-07-03 Thread 12345swordy via Digitalmars-d
On Thursday, 28 June 2018 at 13:24:11 UTC, Timon Gehr wrote: On 26.06.2018 11:55, Francesco Mecca 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: [...] What is the status of the DIP? Is

Re: Tuple DIP

2018-06-28 Thread Timon Gehr via Digitalmars-d
On 26.06.2018 11:55, Francesco Mecca 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: [...] What is the status of the DIP? Is it ready to be proposed and dicussed? I still need to

Re: Tuple DIP

2018-06-27 Thread 12345swordy via Digitalmars-d
On Tuesday, 26 June 2018 at 09:55:10 UTC, Francesco Mecca 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: [...] What is the status of the DIP? Is it ready to be proposed and dicussed?

Re: Tuple DIP

2018-06-26 Thread Francesco Mecca via Digitalmars-d
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: [...] What is the status of the DIP? Is it ready to be proposed and dicussed?

Re: Tuple DIP

2018-05-02 Thread Timon Gehr via Digitalmars-d
On 15.03.2018 17:14, Timon Gehr wrote: We could make lambdas consistent with proposal 5: ... Good point. That's indeed the intention, but I didn't get around to updating the grammar section. Nevermind, it's already there, as the grammar shares "Parameters" between functions and function

Re: Tuple DIP

2018-03-15 Thread Timon Gehr via Digitalmars-d
On 15.03.2018 14:42, Nick Treleaven wrote: On Wednesday, 17 January 2018 at 06:44:21 UTC, Timon Gehr wrote: It uses tuples because it uses zip. The code does not compile today, because the lambda I'm passing to "map" has two parameters: auto a = [1, 2, 4, 7, 2]; auto b = [3, 5, 3, 2, 4]; //

Re: Tuple DIP

2018-03-15 Thread Timon Gehr via Digitalmars-d
On 15.03.2018 11:45, ixid wrote: On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote: auto (a, b) = (1, 2); For the assignment and unpacking grammar why not adopt [...] Go syntax? ... It does not fit in. auto a, b = 1, 2; // Creates two new variables with the values 1 and 2 auto

Re: Tuple DIP

2018-03-15 Thread Seb via Digitalmars-d
On Thursday, 15 March 2018 at 14:11:47 UTC, Stefan Koch wrote: On Thursday, 15 March 2018 at 14:07:12 UTC, JN 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:

Re: Tuple DIP

2018-03-15 Thread Stefan Koch via Digitalmars-d
On Thursday, 15 March 2018 at 14:07:12 UTC, JN 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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md I may be out of the loop

Re: Tuple DIP

2018-03-15 Thread JN via Digitalmars-d
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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md I may be out of the loop here, but what is the actual usecase for tuples? What

Re: Tuple DIP

2018-03-15 Thread Nick Treleaven via Digitalmars-d
On Wednesday, 17 January 2018 at 06:44:21 UTC, Timon Gehr wrote: It uses tuples because it uses zip. The code does not compile today, because the lambda I'm passing to "map" has two parameters: auto a = [1, 2, 4, 7, 2]; auto b = [3, 5, 3, 2, 4]; // auto c = zip(a, b).map!((x, y) => x + y);

Re: Tuple DIP

2018-03-15 Thread ixid via Digitalmars-d
On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote: auto (a, b) = (1, 2); For the assignment and unpacking grammar why not adopt the more streamlined Go syntax? auto a, b = 1, 2; // Creates two new variables with the values 1 and 2 auto c, d = 1, (2,3); // A normal variable and

Re: Tuple DIP

2018-02-19 Thread Timon Gehr via Digitalmars-d
On 20.02.2018 01:57, Timothee Cour wrote: On Mon, Feb 19, 2018 at 4:05 PM, Timon Gehr via Digitalmars-d wrote: On 20.02.2018 00:53, Timothee Cour wrote: Sure! Also, this: void main(string[] args){ enforce(args.length==5, "Invalid args"); auto (infile,

Re: Tuple DIP

2018-02-19 Thread Timothee Cour via Digitalmars-d
On Mon, Feb 19, 2018 at 4:05 PM, Timon Gehr via Digitalmars-d wrote: > On 20.02.2018 00:53, Timothee Cour wrote: >> > Sure! Also, this: > > void main(string[] args){ > enforce(args.length==5, "Invalid args"); > auto (infile, colname, repl, outfile) =

Re: Tuple DIP

2018-02-19 Thread Timon Gehr via Digitalmars-d
On 20.02.2018 00:53, Timothee Cour wrote: great! maybe worth adding to DIP? (even though `unpack` would be (IIUC) a pure library solution on top of this DIP) ... Yes. I'll add it to the use cases. and that would work too I guess? ``` string[4] args=...; auto (infile, colname, repl, outfile)

Re: Tuple DIP

2018-02-19 Thread Timothee Cour via Digitalmars-d
great! maybe worth adding to DIP? (even though `unpack` would be (IIUC) a pure library solution on top of this DIP) and that would work too I guess? ``` string[4] args=...; auto (infile, colname, repl, outfile) = args.unpack; ``` On Mon, Feb 19, 2018 at 3:47 PM, Timon Gehr via Digitalmars-d

Re: Tuple DIP

2018-02-19 Thread Timon Gehr via Digitalmars-d
On 20.02.2018 00:43, Timon Gehr wrote: void main(){     auto (infile, colname, repl, outfile) = args[1..$].unpack!4("Invalid args\n"); } Actually: void main(string[] args){ auto (infile, colname, repl, outfile) = args[1..$].unpack!4("Invalid args\n"); }

Re: Tuple DIP

2018-02-19 Thread Timon Gehr via Digitalmars-d
On 20.02.2018 00:19, timotheecour 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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md This DIP aims to make code like the

Re: Tuple DIP

2018-02-19 Thread timotheecour via Digitalmars-d
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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md This DIP aims to make code like the following valid D: ... Would this DIP

Re: Tuple DIP

2018-02-16 Thread Timon Gehr via Digitalmars-d
On 16.02.2018 20:51, Martin Nowak wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 01/12/2018 11:44 PM, Timon Gehr wrote: As promised [1], I have started setting up a DIP to improve tuple ergonomics in D: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md Pardon me

Re: Tuple DIP

2018-02-16 Thread Timon Gehr via Digitalmars-d
On 16.02.2018 21:01, Martin Nowak wrote: On 01/14/2018 12:21 AM, Timon Gehr wrote: what would be the equivalent of this ? ` writeln(tuple!("x", "y", "z")(2, 3, 4).y); ` It would continue to work the same way. I did consider adding a proposal for built-in named tuple syntax: writeln((x: 2,

Re: Tuple DIP

2018-02-16 Thread Timon Gehr via Digitalmars-d
On 16.02.2018 21:16, Jonathan M Davis wrote: On Friday, February 16, 2018 21:01:02 Martin Nowak via Digitalmars-d wrote: On 01/14/2018 12:21 AM, Timon Gehr wrote: what would be the equivalent of this ? ` writeln(tuple!("x", "y", "z")(2, 3, 4).y); ` It would continue to work the same way. I

Re: Tuple DIP

2018-02-16 Thread Timon Gehr via Digitalmars-d
On 16.02.2018 21:48, H. S. Teoh wrote: On Fri, Feb 16, 2018 at 01:16:13PM -0700, Jonathan M Davis via Digitalmars-d wrote: On Friday, February 16, 2018 21:01:02 Martin Nowak via Digitalmars-d wrote: On 01/14/2018 12:21 AM, Timon Gehr wrote: what would be the equivalent of this ? `

Re: Tuple DIP

2018-02-16 Thread H. S. Teoh via Digitalmars-d
On Fri, Feb 16, 2018 at 01:16:13PM -0700, Jonathan M Davis via Digitalmars-d wrote: > On Friday, February 16, 2018 21:01:02 Martin Nowak via Digitalmars-d wrote: > > On 01/14/2018 12:21 AM, Timon Gehr wrote: > > >> what would be the equivalent of this ? > > >> ` writeln(tuple!("x", "y", "z")(2,

Re: Tuple DIP

2018-02-16 Thread Jonathan M Davis via Digitalmars-d
On Friday, February 16, 2018 21:01:02 Martin Nowak via Digitalmars-d wrote: > On 01/14/2018 12:21 AM, Timon Gehr wrote: > >> what would be the equivalent of this ? > >> ` writeln(tuple!("x", "y", "z")(2, 3, 4).y); ` > > > > It would continue to work the same way. > > > > I did consider adding a

Re: Tuple DIP

2018-02-16 Thread Martin Nowak via Digitalmars-d
On 01/14/2018 12:21 AM, Timon Gehr wrote: >> what would be the equivalent of this ? >> ` writeln(tuple!("x", "y", "z")(2, 3, 4).y); ` > > It would continue to work the same way. > > I did consider adding a proposal for built-in named tuple syntax: > > writeln((x: 2, y: 3, z: 4).y); > > (int a,

Re: Tuple DIP

2018-02-16 Thread Martin Nowak via Digitalmars-d
On 01/14/2018 07:41 PM, Timothee Cour wrote: > Should definitely be mentioned in the DIP to open that up for discussion; > it breaks assumptions like sizeof(Tuple)=sum_i : tuple (sizeof(Ti)); That doesn't hold for all cases anyhow, as it seems were talking about closed tuples that are contiguous

Re: Tuple DIP

2018-02-16 Thread Martin Nowak via Digitalmars-d
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On 01/12/2018 11:44 PM, Timon Gehr wrote: > As promised [1], I have started setting up a DIP to improve tuple > ergonomics in D: > > https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md Pardon me if things have been said already,

Re: Tuple DIP

2018-01-30 Thread Seb via Digitalmars-d
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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md This DIP aims to make code like the following valid D: --- auto (a, b) = (1,

Re: Tuple DIP

2018-01-23 Thread Atila Neves via Digitalmars-d
On Tuesday, 23 January 2018 at 14:58:07 UTC, Petar Kirov [ZombineDev] wrote: On Tuesday, 23 January 2018 at 11:04:33 UTC, Atila Neves wrote: On Sunday, 14 January 2018 at 18:17:38 UTC, Timon Gehr wrote: On 14.01.2018 19:14, Timothee Cour wrote: actually I just learned that indeed

Re: Tuple DIP

2018-01-23 Thread Petar via Digitalmars-d
On Tuesday, 23 January 2018 at 11:04:33 UTC, Atila Neves wrote: On Sunday, 14 January 2018 at 18:17:38 UTC, Timon Gehr wrote: On 14.01.2018 19:14, Timothee Cour wrote: actually I just learned that indeed sizeof(typeof(tuple()))=1, but why is that? (at least for std.typecons.tuple) maybe worth

Re: Tuple DIP

2018-01-23 Thread Atila Neves via Digitalmars-d
On Sunday, 14 January 2018 at 18:17:38 UTC, Timon Gehr wrote: On 14.01.2018 19:14, Timothee Cour wrote: actually I just learned that indeed sizeof(typeof(tuple()))=1, but why is that? (at least for std.typecons.tuple) maybe worth mentioning that in the DIP (with rationale) It's inherited

Re: Tuple DIP

2018-01-17 Thread Ola Fosheim Grøstad via Digitalmars-d
On Wednesday, 17 January 2018 at 19:43:03 UTC, Manu wrote: I quite like C++ explicit unpacking (using ...), and I wouldn't be upset to see that appear here too. FWIW C++17 has structured binding: http://en.cppreference.com/w/cpp/language/structured_binding auto [x,y] = f()

Re: Tuple DIP

2018-01-17 Thread Timon Gehr via Digitalmars-d
On 17.01.2018 20:43, Manu wrote: On 12 January 2018 at 14:44, Timon Gehr via Digitalmars-d > wrote: As promised [1], I have started setting up a DIP to improve tuple ergonomics in D:

Re: Tuple DIP

2018-01-17 Thread Manu via Digitalmars-d
On 12 January 2018 at 14:44, Timon Gehr via Digitalmars-d < digitalmars-d@puremagic.com> wrote: > As promised [1], I have started setting up a DIP to improve tuple > ergonomics in D: > > https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md > > > This DIP aims to make code like the

Re: Tuple DIP

2018-01-17 Thread aliak via Digitalmars-d
On Tuesday, 16 January 2018 at 21:21:04 UTC, Timon Gehr wrote: My thoughts were: http://forum.dlang.org/post/p3e4al$1jfc$1...@digitalmars.com But as it has been requested more than once and it is a feature of existing Phobos tuples, I can add a proposal to the DIP that can be

Re: Tuple DIP

2018-01-17 Thread Steven Schveighoffer via Digitalmars-d
On 1/17/18 1:44 AM, Timon Gehr wrote: On 17.01.2018 02:20, Steven Schveighoffer wrote: On 1/12/18 5:44 PM, Timon Gehr wrote: As promised [1], I have started setting up a DIP to improve tuple ergonomics in D: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md Awesome! I can

Re: Tuple DIP

2018-01-16 Thread Timon Gehr via Digitalmars-d
On 17.01.2018 02:20, Steven Schveighoffer wrote: On 1/12/18 5:44 PM, Timon Gehr wrote: As promised [1], I have started setting up a DIP to improve tuple ergonomics in D: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md Awesome! I can say I felt a lot more comfortable with

Re: Tuple DIP

2018-01-16 Thread Steven Schveighoffer via Digitalmars-d
On 1/12/18 5:44 PM, Timon Gehr wrote: As promised [1], I have started setting up a DIP to improve tuple ergonomics in D: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md Awesome! I can say I felt a lot more comfortable with the trailing-comma syntax after our last

Re: Tuple DIP

2018-01-16 Thread Guillaume Boucher via Digitalmars-d
On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote: foreach((sum, diff); [(1, 2), (4, 3)].map!((a, b) => (a + b, a - b))) { writeln(sum, " ", diff); } I'm not a big fan of the foreach syntax. It's so easy to forget or accidentally add parentheses while coding, or read it

Re: Tuple DIP

2018-01-16 Thread Timon Gehr via Digitalmars-d
On 16.01.2018 22:46, jmh530 wrote: On Tuesday, 16 January 2018 at 21:21:04 UTC, Timon Gehr wrote: My thoughts were: http://forum.dlang.org/post/p3e4al$1jfc$1...@digitalmars.com A starting point could be an unnamed tuple built-in tuple type, but also not yet deprecating the built-in named

Re: Tuple DIP

2018-01-16 Thread jmh530 via Digitalmars-d
On Tuesday, 16 January 2018 at 21:21:04 UTC, Timon Gehr wrote: My thoughts were: http://forum.dlang.org/post/p3e4al$1jfc$1...@digitalmars.com A starting point could be an unnamed tuple built-in tuple type, but also not yet deprecating the built-in named tuple type in std.typecons. But

Re: Tuple DIP

2018-01-16 Thread Timon Gehr via Digitalmars-d
On 16.01.2018 22:03, aliak 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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md ... Oh Yes! Question, would named tuples be

Re: Tuple DIP

2018-01-16 Thread aliak via Digitalmars-d
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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md ... Oh Yes! Question, would named tuples be able to be worked in or is that

Re: Tuple DIP - tuple unification with arrays and structs

2018-01-15 Thread Walter Bright via Digitalmars-d
On 1/14/2018 6:55 AM, Q. Schroll wrote: How is (1, 2) different from [1, 2] (static array)? It's a very good question. It's corollary is how is (1, 2) different from struct S { int a, b; } It does turn out that int[2] is structurally (!) the same as struct S. This is a property I've taken

Re: Tuple DIP

2018-01-15 Thread Walter Bright via Digitalmars-d
On 1/14/2018 10:17 AM, Timon Gehr wrote: It's inherited from C, where all struct instances have size at least 1. (Such that each of them has a distinct address.) There are some peculiarities with that, like with multiple inheritance sometimes the size really is zero :-)

Re: Tuple DIP

2018-01-14 Thread Timothee Cour via Digitalmars-d
On Sun, Jan 14, 2018 at 10:17 AM, Timon Gehr via Digitalmars-d wrote: > On 14.01.2018 19:14, Timothee Cour wrote: >> >> actually I just learned that indeed sizeof(typeof(tuple()))=1, but why >> is that? (at least for std.typecons.tuple) >> maybe worth mentioning that

Re: Tuple DIP

2018-01-14 Thread Timon Gehr via Digitalmars-d
On 14.01.2018 19:14, Timothee Cour wrote: actually I just learned that indeed sizeof(typeof(tuple()))=1, but why is that? (at least for std.typecons.tuple) maybe worth mentioning that in the DIP (with rationale) It's inherited from C, where all struct instances have size at least 1. (Such

Re: Tuple DIP

2018-01-14 Thread Timothee Cour via Digitalmars-d
actually I just learned that indeed sizeof(typeof(tuple()))=1, but why is that? (at least for std.typecons.tuple) maybe worth mentioning that in the DIP (with rationale) On Sun, Jan 14, 2018 at 8:18 AM, Timon Gehr via Digitalmars-d wrote: > On 14.01.2018 15:55, Q.

Re: Tuple DIP

2018-01-14 Thread Timon Gehr via Digitalmars-d
On 14.01.2018 15:55, Q. Schroll wrote: On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote: [...] This DIP aims to make code like the following valid D: --- auto (a, b) = (1, 2); (int a, int b) = (1, 2); --- [...] How is (1, 2) different from [1, 2] (static array)? The first is a

Re: Tuple DIP

2018-01-14 Thread Q. Schroll via Digitalmars-d
On Sunday, 14 January 2018 at 00:01:15 UTC, rikki cattermole wrote: On 13/01/2018 11:45 PM, Timothee Cour wrote: some people have suggested using `{a, b}` instead of `(a,b)` ; this would not work because of ambiguity, eg: `auto fun(){ return {}; }` already has a meaning, so the empty tuple

Re: Tuple DIP

2018-01-14 Thread Q. Schroll via Digitalmars-d
On Friday, 12 January 2018 at 22:44:48 UTC, Timon Gehr wrote: [...] This DIP aims to make code like the following valid D: --- auto (a, b) = (1, 2); (int a, int b) = (1, 2); --- [...] How is (1, 2) different from [1, 2] (static array)? It makes no sense to me to have both and probably a

Re: Tuple DIP

2018-01-13 Thread rikki cattermole via Digitalmars-d
On 13/01/2018 11:45 PM, Timothee Cour wrote: some people have suggested using `{a, b}` instead of `(a,b)` ; this would not work because of ambiguity, eg: `auto fun(){ return {}; }` already has a meaning, so the empty tuple would not work. so `()` is indeed better. Easy fix, tuples must have a

Re: Tuple DIP

2018-01-13 Thread Timothee Cour via Digitalmars-d
some people have suggested using `{a, b}` instead of `(a,b)` ; this would not work because of ambiguity, eg: `auto fun(){ return {}; }` already has a meaning, so the empty tuple would not work. so `()` is indeed better. On Fri, Jan 12, 2018 at 2:44 PM, Timon Gehr via Digitalmars-d

Re: Tuple DIP

2018-01-13 Thread Timon Gehr via Digitalmars-d
On 13.01.2018 23:57, Timothee Cour wrote: the DIP says this replace std.typecons.TypeTuple however no mention is made of named arguments, so I don't see how they could be a replacement (nor how would that allow for a migration path) without mentioning a word on this, eg: what would be the

Re: Tuple DIP

2018-01-13 Thread Timothee Cour via Digitalmars-d
the DIP says this replace std.typecons.TypeTuple however no mention is made of named arguments, so I don't see how they could be a replacement (nor how would that allow for a migration path) without mentioning a word on this, eg: what would be the equivalent of this ? ` writeln(tuple!("x", "y",

Re: Tuple DIP

2018-01-13 Thread Timothee Cour via Digitalmars-d
it would also solve a long-standing issue of passing runtime optional arguments along with variadic templates, eg: current: ``` # current: bad, causes template bloat (1 template per call site) void log(string file=__FILE__, int line=__LINE__, T...)(T a); # usage: log(1, "foo"); # with this DIP

Re: Tuple DIP

2018-01-13 Thread MrSmith via Digitalmars-d
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(); =>

Re: Tuple DIP

2018-01-13 Thread rjframe via Digitalmars-d
On Sat, 13 Jan 2018 22:10:39 +, rjframe wrote: > On Sat, 13 Jan 2018 21:57:31 +0100, Timon Gehr wrote: > >> On 13.01.2018 21:39, rjframe wrote: >>> Python and Pony use (). C++17 uses []. >> >> Any idea why C++17 went with [] ? > > I don't know; the paper[1] says it was due to "feedback

Re: Tuple DIP

2018-01-13 Thread Mark via Digitalmars-d
On Saturday, 13 January 2018 at 20:57:31 UTC, Timon Gehr wrote: On 13.01.2018 21:39, rjframe wrote: Python and Pony use (). C++17 uses []. Any idea why C++17 went with [] ? Perhaps D should use <>? [not a serious question] It was hard for me not to use angled brackets for templates when I

Re: Tuple DIP

2018-01-13 Thread rjframe via Digitalmars-d
On Sat, 13 Jan 2018 21:57:31 +0100, Timon Gehr wrote: > On 13.01.2018 21:39, rjframe wrote: >> Python and Pony use (). C++17 uses []. > > Any idea why C++17 went with [] ? I don't know; the paper[1] says it was due to "feedback from the EWG session in Jacksonville". > > It would actually be

Re: Tuple DIP

2018-01-13 Thread Timon Gehr via Digitalmars-d
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];

Re: Tuple DIP

2018-01-13 Thread Timon Gehr via Digitalmars-d
On 13.01.2018 21:39, rjframe wrote: Python and Pony use (). C++17 uses []. Any idea why C++17 went with [] ? Perhaps D should use <>? [not a serious question] It was hard for me not to use angled brackets for templates when I started with D, but now it's second nature. I think you're right,

Re: Tuple DIP

2018-01-13 Thread Timon Gehr via Digitalmars-d
On 13.01.2018 20:43, aberba wrote: When I raised this feature for D, suggestions on the use of () instead of {} got me concerned. All languages that I know to have this feature (known as destructuring) use curly braces. It seems that this is actually not the case. Anyway, I'd suggest having

Re: Tuple DIP

2018-01-13 Thread rjframe via Digitalmars-d
On Sat, 13 Jan 2018 19:43:48 +, aberba wrote: > > When I raised this feature for D, suggestions on the use of () instead > of {} got me concerned. All languages that I know to have this feature > (known as destructuring) use curly braces. Thats what kotlin and > JavaScript (that I know have

Re: Tuple DIP

2018-01-13 Thread aberba via Digitalmars-d
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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md This DIP aims to make code like the following valid D: --- auto (a, b) = (1,

Re: Tuple DIP

2018-01-13 Thread Timon Gehr via Digitalmars-d
On 13.01.2018 19:11, Timothee Cour wrote: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md#proposal-6-placeholder-name-_ Symbols with the name _ should not be inserted into the symbol table. why not use `?` instead of `_` ? no breaking change and should be unambiguous with

Re: Tuple DIP

2018-01-13 Thread Timon Gehr via Digitalmars-d
On 13.01.2018 19:07, Timothee Cour wrote: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md#proposal-4-unpacking-assignments ``` (a, b) = t; // shouldn't it be: auto (a, b) = t; ``` ? No, but there was a mistake in the code that explains the confusion. It should be: (int,

Re: Tuple DIP

2018-01-13 Thread Timothee Cour via Digitalmars-d
https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md#proposal-6-placeholder-name-_ > Symbols with the name _ should not be inserted into the symbol table. why not use `?` instead of `_` ? no breaking change and should be unambiguous with (expr ? expr : expr) syntax On Fri, Jan

Re: Tuple DIP

2018-01-13 Thread Timothee Cour via Digitalmars-d
https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md#proposal-4-unpacking-assignments ``` (a, b) = t; // shouldn't it be: auto (a, b) = t; ``` ? On Sat, Jan 13, 2018 at 9:52 AM, Mengu via Digitalmars-d wrote: > On Friday, 12 January 2018 at 22:44:48

Re: Tuple DIP

2018-01-13 Thread Mengu via Digitalmars-d
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: [...] how do we vote for / support this DIP?

Re: Tuple DIP

2018-01-13 Thread Ilya Yaroshenko via Digitalmars-d
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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md [1] https://forum.dlang.org/post/or625h$2hns$1...@digitalmars.com Awesome!!!

Re: Tuple DIP

2018-01-13 Thread Timon Gehr via Digitalmars-d
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

Re: Tuple DIP

2018-01-13 Thread Timon Gehr via Digitalmars-d
On 13.01.2018 12:43, Jacob Carlborg wrote: 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

Re: Tuple DIP

2018-01-13 Thread Nordlöw via Digitalmars-d
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.

Re: Tuple DIP

2018-01-13 Thread Jacob Carlborg via Digitalmars-d
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"

Re: Tuple DIP

2018-01-13 Thread Mark via Digitalmars-d
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

Re: Tuple DIP

2018-01-12 Thread jmh530 via Digitalmars-d
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)

Re: Tuple DIP

2018-01-12 Thread Basile B. via Digitalmars-d
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

Re: Tuple DIP

2018-01-12 Thread Basile B. via Digitalmars-d
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

Re: Tuple DIP

2018-01-12 Thread Basile B. via Digitalmars-d
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

Re: Tuple DIP

2018-01-12 Thread jmh530 via Digitalmars-d
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

Re: Tuple DIP

2018-01-12 Thread SrMordred via Digitalmars-d
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.

Re: Tuple DIP

2018-01-12 Thread rikki cattermole via Digitalmars-d
On 12/01/2018 10:44 PM, Timon Gehr wrote: As promised [1], I have started setting up a DIP to improve tuple ergonomics in D: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md This DIP aims to make code like the following valid D: --- auto (a, b) = (1, 2); (int a, int b) =

Re: Tuple DIP

2018-01-12 Thread Timon Gehr via Digitalmars-d
On 13.01.2018 01:20, Mark wrote: Could we also support function tuples? In principle, yes, though I imagine it is a lot harder to argue for its inclusion than for that of the features currently proposed in the DIP, because existing language features already come rather close. For

Re: Tuple DIP

2018-01-12 Thread Rubn via Digitalmars-d
Should include an example of returning a tuple from a function. I know one of the pains with variadic templates is that they can't be returned. So maybe something that goes over the following use case: auto returnTuple(Args...)(Args args) { return args; } (int a, float b) =

Re: Tuple DIP

2018-01-12 Thread Chris M. via Digitalmars-d
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

Re: Tuple DIP

2018-01-12 Thread Timon Gehr via Digitalmars-d
On 13.01.2018 00:16, Basile B. 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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md markdown trick: you can use ```diff ```

Re: Tuple DIP

2018-01-12 Thread Mark via Digitalmars-d
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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md This DIP aims to make code like the following valid D: --- auto (a, b) = (1,

Re: Tuple DIP

2018-01-12 Thread Basile B. via Digitalmars-d
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: https://github.com/tgehr/DIPs/blob/tuple-syntax/DIPs/DIP1xxx-tg.md markdown trick: you can use ```diff ``` for a nicer grammar section.

Re: Tuple DIP

2018-01-12 Thread Timon Gehr via Digitalmars-d
On 12.01.2018 23:44, Timon Gehr wrote: --- auto (a, b) = (1, 2); (int a, int b) = (1, 2); --- (The two lines are two independent examples :o).)

Re: Tuple DIP

2018-01-12 Thread Timon Gehr via Digitalmars-d
On 12.01.2018 23:44, Timon Gehr wrote: ... Before going ahead with it, I'd like some preliminary community input: ... Also, if you have more links to forum posts requesting related features, that would be useful (googling turned up the ones that are in the DIP, but I know that there were