Discussion Thread: DIP 1030--Named Arguments--Final Review

jmh530 john.michael.hall at gmail.com
Thu May 14 20:20:41 UTC 2020


On Tuesday, 12 May 2020 at 18:57:25 UTC, jmh530 wrote:
> On Monday, 11 May 2020 at 11:37:07 UTC, Mike Parker wrote:
>> [snip]
>
> I think the comments in the prior discussion with respect to 
> Python's positional-only and keyword-only arguments make sense 
> (see [1] for the PEP on this). In particular, the only change I 
> would make to this DIP would be to make it so that keyword 
> arguments are opt-in, such asmaking the syntax something like
> auto functionName(positional_only_parameters, /, 
> positional_or_keyword_parameters) {}
> [snip]

Given the recent discussions, I am reconsidering what I said 
above.

First, Seb's extern(D, argNames) (or other bikeshedded name) 
seems worth including. It would mean that keyword_only_parameters 
could potentially be emulated for people who need that. extern(D, 
argNames) wouldn't apply to positional_only_parameters.

However, I have reconsidered keeping positional-only as the 
default. Instead, I would have what this DIP suggests as the 
default, as in
auto functionName(positional_or_keyword_parameters) {}
However, I would also allow an opt-in for positional only 
parameters, so that the full syntax would be
auto functionName(positional_only_parameters, /, 
positional_or_keyword_parameters) {}

Recall Paul's argument (that Walter approved of) that there 
should be only one set of rules and we already have the struct 
initialization rules. From the perspective of these edits, the 
struct initialization rules would be the special case of these 
for wen there are no positional_only_parameters. Only one set of 
rules is needed, but you add the ability to handle deprecations 
and allow positional_only_parameters without resorting to hacks 
or long, ugly names.


More information about the Digitalmars-d mailing list