On 2015-07-24 16:15, Shammah Chancellor wrote:
Since D has optional arguments -- why don't we support named
parameters?  There are extremely handy and work beautifully in languages
like C#.

I think it would really good to have in D, especially since bool parameters are basically banned in favor a struct:

// banned
string toString(bool prettyPrint);
toString(false);

// preferred
string toString(PrettyPrint p);
toString(PrettyPrint.no);

// With named parameters
string toString(bool prettyPrint);
toString(prettyPrint: true);

If named parameters don't allow reordering it won't be a problem with overloading.

A simple implementation:

https://github.com/jacob-carlborg/dmd/tree/named_parameters

--
/Jacob Carlborg

Reply via email to