Named parameters
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Sat Jul 25 03:32:44 PDT 2015
On Saturday, 25 July 2015 at 09:41:19 UTC, Jacob Carlborg wrote:
> On 2015-07-24 23:04, Walter Bright wrote:
>
>> The question is what problem does it solve.
>
> For one thing, it avoids the ugly hack which is the Flag
> template and Yes/No structs.
>
> With Flag:
>
> string getLine(Flag!"keepTerminator" keepTerminator);
> getLine(Flag!"keepTerminator".yes);
>
> With named parameters:
>
> string getLine(bool keepTerminator);
> getLine(keepTerminator: true);
If Andrei weren't insisting that we use that idiom everywhere in
Phobos, I'd honestly just be using bools and be done with it. It
adds some value, but I seriously question that it's worth the
extra verbosity. But regardless, I'd hate to see named arguments
get added to the language just to clean that mess up.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list