digitalmars.D - Skipping function parameters with default value
- tcak (12/12) May 21 2015 Does D has an aim to be convertible back to C code easily?
- Liam McSherry (4/20) May 21 2015 Parameters with default values must be at the end of the set of
Does D has an aim to be convertible back to C code easily? I want to define a function as follows: mysqlConnect( string host="localhost", string username, string password=null ); I was expecting that I could call the function as follows: mysqlConnect( , "root" ); But, it neither allows me to define the function in that way, or allows me to call the function in that way even if I give a default value to username parameter. Would it be possible to allow a syntax as above? This could open the doors to set parameters by giving parameter name as well.
May 21 2015
On Thursday, 21 May 2015 at 21:08:02 UTC, tcak wrote:Does D has an aim to be convertible back to C code easily? I want to define a function as follows: mysqlConnect( string host="localhost", string username, string password=null ); I was expecting that I could call the function as follows: mysqlConnect( , "root" ); But, it neither allows me to define the function in that way, or allows me to call the function in that way even if I give a default value to username parameter. Would it be possible to allow a syntax as above? This could open the doors to set parameters by giving parameter name as well.Parameters with default values must be at the end of the set of parameters in the function definition. For example, instead of:mysqlConnect( string host="localhost", string username, string password=null );It would need to be:mysqlConnect( string username, string host="localhost", string password=null );
May 21 2015