On 2016-01-23 15:54, Marc Schütz wrote:

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.

I can add an example.

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).

Take this for example:

void foo(int a, string b);
void foo(string b, int a);

void main()
{
    foo(3, "asd");
    foo("asd", 3);
}

The above is legal today. The same example with named arguments:

void foo(int a:, string b:);
void foo(string b:, int a:);

void main()
{
    foo(a: 3, b: "asd");
}

What should happen in the above example? Error or which function should be called?

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?

I haven't really though of that. My initial though would be to not allow that for simplicity. I want to keep it fairly simple to have a chance for the proposal to be accepted.

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?

We already have ParameterIdentifierTuple [1]. Are you thinking of something else?

I'm not seeing how AliasSeq is related but this PR [2] adds template parameter introspection traits.

[1] http://dlang.org/phobos/std_traits.html#ParameterIdentifierTuple
[2] https://github.com/D-Programming-Language/dmd/pull/5201

--
/Jacob Carlborg

Reply via email to