Re: function default arguments depending on other arguments

2014-07-21 Thread Andrei Alexandrescu via Digitalmars-d
On 7/20/14, 2:22 AM, Tove wrote: On Friday, 18 July 2014 at 17:40:23 UTC, Timon Gehr wrote: On 07/18/2014 12:00 AM, Trass3r wrote: void foo(int a, int b = a) { } is illegal in C++ because order of evaluation is undefined. But since D defines the order to be left to right couldn't it also

Re: function default arguments depending on other arguments

2014-07-20 Thread Tove via Digitalmars-d
On Friday, 18 July 2014 at 17:40:23 UTC, Timon Gehr wrote: On 07/18/2014 12:00 AM, Trass3r wrote: void foo(int a, int b = a) { } is illegal in C++ because order of evaluation is undefined. But since D defines the order to be left to right couldn't it also allow this? It could, and I think

Re: function default arguments depending on other arguments

2014-07-20 Thread bearophile via Digitalmars-d
Tove: IIRC: Walter's stance was that he needs compelling examples, which proves the utility of this new feature. Recently I have had a desire for that feature, to write a function like this: int[][] generateTable(in uint nx, in uint ny=nx) {...} If you give just one argument to this

Re: function default arguments depending on other arguments

2014-07-18 Thread Timon Gehr via Digitalmars-d
On 07/18/2014 12:00 AM, Trass3r wrote: void foo(int a, int b = a) { } is illegal in C++ because order of evaluation is undefined. But since D defines the order to be left to right couldn't it also allow this? It could, and I think it is an unnecessary limitation that it currently does not.

function default arguments depending on other arguments

2014-07-17 Thread Trass3r via Digitalmars-d
void foo(int a, int b = a) { } is illegal in C++ because order of evaluation is undefined. But since D defines the order to be left to right couldn't it also allow this?