DIP 1020--Named Parameters--Community Review Round 2

rikki cattermole rikki at cattermole.co.nz
Tue Sep 10 12:37:27 UTC 2019


On 10/09/2019 11:51 PM, SashaGreat wrote:
>> Different options for opt-in named parameter syntax have been proposed 
>> and discussed in the D programming language community. DIP 88 proposed 
>> a colon to denote a named parameter, DIP 1019 originally proposed the 
>> use of the @named function attribute, and this DIP originally proposed 
>> that angle brackets be used to denote named parameters. After feedback 
>> from the first round of review, this DIP has been amended to propose 
>> an new @named attribute with which to annotate parameters rather than 
>> functions.
> 
>> struct Map(@named alias Function, @named InputType, @named ElementType)
> 
> As a C# programmer which has this feature too, this is excessively noise 
> in contrast.
> 
> Wouldn't be easier to go with Opt-Out (Or In) with a flag on Compiler 
> level?
> 
> S.

That would require a different design and I am not sure that it would be 
a good design element to incorporate.

I am happy to consider other options (@named was an option that was 
proposed in CR 1 that got a bit of support), however I am unsure if 
there is a better design waiting to be discovered.



In the example you referenced, the example in question over uses named 
parameters imo, for the purposes of demonstrating what it is capable of.

If that was a real example it should look somewhat like:

```
auto map(alias Function, InputType)(InputType input) {
	return Map!(Function, InputType)(input);
}

struct Map(alias Function, InputType,
	@named ElementType = ElementType!InputType)
```

Actionable list with this example listed on it is available here: 
https://gist.github.com/rikkimax/91d0291da30d6ed161c6d3fa89868883


More information about the Digitalmars-d mailing list