Allow empty field function arguments for default?
Jacob Carlborg
doob at me.com
Thu Apr 19 11:34:41 PDT 2012
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);
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list