On 04/06/2018 5:01 PM, Mike Parker wrote:
Named arguments lite

I'm concerned about this DIP (keep in mind I wrote a referenced WIP DIP).

1. Reordering of parameters that match (with overloads)

```D
int add(int a, int b);
int add(int b, int a) { ... }
```

This part of the DIP needs quite a bit of filling out and I expect to have a lot of corner cases.

Are you saying that you have an add that is extern'd or do you mean a named argument function overload? By conventional wisdom it definitely should error out.

I'm sure somebody else can think of more problems with this with regards to types.

2. All or nothing.

```D
int add(int x, int y);
@named:
int add(int b, int a) { ... }
```

This is one of the reasons some people /don't/ want named arguments and have said that they out right would not use a language with it.

3. Admittedly this is meant to be a cut down version, so I'll leave this use case here which named arguments should fix (I think).

```D
void main() {
        log("hi!");
        log(moduleName: "woot", lineNumber: 7, "bye");
}

void log(T...)(T args, <string moduleName = __MODULE__, uint lineNumber = __LINE__>) {
    writeln(moduleName, "[", lineNumber, "] ", args);
}
```

Reply via email to