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

sarn sarn at theartofmachinery.com
Mon Apr 1 23:11:33 UTC 2019


On Monday, 1 April 2019 at 20:36:47 UTC, arturg wrote:
> Whats the big issue with named parameters, why cant D have them 
> with the same restriction as C#?
>
> foo(3, 4, x=5, y=6, z=7) works
> foo(3, x=5, 4, y=6, z=7) does'nt, because every paremeter after 
> a named one has to be a named parameter

+1 It's the same rule as in Python and others, and it works.  
Mixing positional/named parameters makes the call harder to read. 
  (Think quick: which positional parameter does the 4 in the 
example refer to?)

Reordering named parameters is useful because if the parameters 
are named, that probably means the names are more semantic than 
the ordering.  Having to remember an arbitrary ordering just 
makes life more difficult.


More information about the Digitalmars-d mailing list