DIP 88: Simple form of named parameters

Marc Schütz via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 23 06:54:18 PST 2016


On Saturday, 23 January 2016 at 14:19:03 UTC, Jacob Carlborg 
wrote:
> This is mostly to prevent ugly hacks like Flag [1].
>
> http://wiki.dlang.org/DIP88
>
> [1] https://dlang.org/phobos/std_typecons.html#.Flag

Some comments:

1) Default values

You should specify how to use both the `:` syntax and a default 
parameter value, including an example. They are often going to be 
used together, and it needs to be clear how they interact.

2) Argument order

I think your rule no. 4 is not really necessary, and actually 
diminishes the usability a lot if there are many name flags. 
Argument reordering can be done as an independent step before 
overload resolution (of course this still needs to be aware of 
all the candidates).

But you should add a note that overloading on parameter names 
alone is illegal (i.e. `void foo(int a:)` vs `void foo(int b:)`). 
That way, they don't need to affect name mangling.

3) Variadic parameters

Is this legal: `void foo(int[] param: ...)`? Or this: `void 
bar(Args...)(Args args:)`? If yes, what would the calling syntax 
look like?

Also, opDispatch is often used for forwarding arguments. Can 
parameter names be forwarded, too? If yes, variadic template 
parameters could capture the names, too, and apply them during 
expansion as appropriate.

4) Traits

Are there going to be traits to inspect the parameter names of a 
function? Of a TypeTuple/AliasTuple/AliasSeq?


More information about the Digitalmars-d mailing list