Re: Lambda syntax for methods and functions

2013-12-10 Thread bearophile
http://adamralph.com/2013/12/06/ndc-diary-day-3/?1 Better explanations: http://damieng.com/blog/2013/12/09/probable-c-6-0-features-illustrated Bye, bearophile

Re: Lambda syntax for methods and functions

2013-12-10 Thread Joshua Niehus
On Saturday, 7 December 2013 at 17:29:43 UTC, bearophile wrote: Even Ada2012 has a similar syntax. I think it's worth having in D. The ER: https://d.puremagic.com/issues/show_bug.cgi?id=7176 Bye, bearophile similar to dart, my 2nd favorite lang :)

Re: Lambda syntax for methods and functions

2013-12-09 Thread monarch_dodra
On Saturday, 7 December 2013 at 20:23:29 UTC, Timon Gehr wrote: On 12/07/2013 07:13 PM, bearophile wrote: Currently in D you can write: enum move = (in int dx, in int dy) pure nothrow = Point(X + dx, Y + dy); I didn't know you could do that, neat. It also means you can do it for implicit

Re: Lambda syntax for methods and functions

2013-12-09 Thread Paulo Pinto
On Sunday, 8 December 2013 at 11:23:48 UTC, bearophile wrote: The relative Reddit thread explains another small feature of the next C#: http://www.reddit.com/r/programming/comments/1sbkxl/a_quick_highlight_of_upcoming_c_language_changes/cdwedrh If I understand that, it's similar to allowing

Re: Lambda syntax for methods and functions

2013-12-09 Thread Craig Dillabaugh
On Sunday, 8 December 2013 at 17:15:42 UTC, Jesse Phillips wrote: On Sunday, 8 December 2013 at 06:58:59 UTC, Marco Leise wrote: But the verbose D syntax is just too distracting: bool function(T a, T b) { return a b; }) I think you mean the verbose D syntax: (a, b) { return a b; }

Re: Lambda syntax for methods and functions

2013-12-08 Thread bearophile
The relative Reddit thread explains another small feature of the next C#: http://www.reddit.com/r/programming/comments/1sbkxl/a_quick_highlight_of_upcoming_c_language_changes/cdwedrh If I understand that, it's similar to allowing D code like this: bool foo(out int x) { x = 10;

Re: Lambda syntax for methods and functions

2013-12-08 Thread Jesse Phillips
On Sunday, 8 December 2013 at 06:58:59 UTC, Marco Leise wrote: But the verbose D syntax is just too distracting: bool function(T a, T b) { return a b; }) I think you mean the verbose D syntax: (a, b) { return a b; }

Re: Lambda syntax for methods and functions

2013-12-08 Thread Marco Leise
Am Sun, 08 Dec 2013 18:15:40 +0100 schrieb Jesse Phillips jesse.k.phillip...@gmail.com: On Sunday, 8 December 2013 at 06:58:59 UTC, Marco Leise wrote: But the verbose D syntax is just too distracting: bool function(T a, T b) { return a b; }) I think you mean the verbose D syntax:

Lambda syntax for methods and functions

2013-12-07 Thread bearophile
From this post: http://adamralph.com/2013/12/06/ndc-diary-day-3/?1 Seems C# will gain this syntax: public Point Move(int dx, int dy) = new Point(X + dx, Y + dy); That means: public Point Move(int dx, int dy) { return new Point(X + dx, Y + dy); } Even Ada2012 has a similar syntax. I think

Re: Lambda syntax for methods and functions

2013-12-07 Thread MattCoder
On Saturday, 7 December 2013 at 17:29:43 UTC, bearophile wrote: public Point Move(int dx, int dy) = new Point(X + dx, Y + dy); That means: public Point Move(int dx, int dy) { return new Point(X + dx, Y + dy); } Maybe It's just me, but on the example above I don't see too much improvement:

Re: Lambda syntax for methods and functions

2013-12-07 Thread MattCoder
Sorry I forgot one thing: On this code: public Point Move(int dx, int dy) { return new Point(X + dx, Y + dy); } It would be too much trouble if the language automatically return the last statement if this was the same type of the method? For example: public Point Move(int dx, int dy){

Re: Lambda syntax for methods and functions

2013-12-07 Thread bearophile
MattCoder: Maybe It's just me, but on the example above I don't see too much improvement: 1 word off (return), and = instead of brackets. In D: Point move(in int dx, in int dy) pure nothrow { return Point(X + dx, Y + dy); } Point move(in int dx, in int dy) pure nothrow = Point(X + dx,

Re: Lambda syntax for methods and functions

2013-12-07 Thread MattCoder
On Saturday, 7 December 2013 at 18:13:06 UTC, bearophile wrote: MattCoder: Maybe It's just me, but on the example above I don't see too much improvement: 1 word off (return), and = instead of brackets. In D: Point move(in int dx, in int dy) pure nothrow { return Point(X + dx, Y + dy);

Re: Lambda syntax for methods and functions

2013-12-07 Thread Timon Gehr
On 12/07/2013 07:13 PM, bearophile wrote: Currently in D you can write: enum move = (in int dx, in int dy) pure nothrow = Point(X + dx, Y + dy); IIRC Don said this shouldn't work since the context is not actually known at compile time.

Re: Lambda syntax for methods and functions

2013-12-07 Thread Jesse Phillips
On Saturday, 7 December 2013 at 17:43:46 UTC, MattCoder wrote: On Saturday, 7 December 2013 at 17:29:43 UTC, bearophile wrote: public Point Move(int dx, int dy) = new Point(X + dx, Y + dy); That means: public Point Move(int dx, int dy) { return new Point(X + dx, Y + dy); } Maybe It's just

Re: Lambda syntax for methods and functions

2013-12-07 Thread bearophile
Timon Gehr: IIRC Don said this shouldn't work since the context is not actually known at compile time. I remember Don saying similar things on some other usages of 'enum'. If all this needs to become accepts-invalid errors, then dmd 2.065 seems a good moment to fix this messy situation.

Re: Lambda syntax for methods and functions

2013-12-07 Thread Marco Leise
Am Sat, 07 Dec 2013 21:21:03 +0100 schrieb Jesse Phillips jesse.k.phillip...@gmail.com: On Saturday, 7 December 2013 at 17:43:46 UTC, MattCoder wrote: On Saturday, 7 December 2013 at 17:29:43 UTC, bearophile wrote: public Point Move(int dx, int dy) = new Point(X + dx, Y + dy); That