On 2012-04-19 20:34, Jacob Carlborg wrote:
On 2012-04-19 16:13, ixid wrote:
I put this here because it's probably a flawed idea. A 'learn' level
suggestion.
At present function arguments that you want to default must go at the
end like so:
int fun(int a = 1, int b = 2, int c = 3)
{
return a + b + c;
}
fun(4); //Modifies a
where the default fields can only be fields after any argument provided.
Why not allow something like:
fun( , 4, ); //Modifies b
fun( , , 5); //Modifies c
for when you want to call fun with other fields not being default? This
would seem more flexible and pretty clear what is intended.
Named arguments would probably be better for this.
fun(c = 5);
Which is actually possible to emulate:
callWithNamedArguments(fun, "c=5");
See:
https://github.com/jacob-carlborg/orange/blob/master/orange/util/Reflection.d#L135
--
/Jacob Carlborg