Named arguments

jmh530 john.michael.hall at gmail.com
Tue Oct 24 20:30:26 UTC 2017


On Tuesday, 24 October 2017 at 19:22:41 UTC, Jonathan M Davis 
wrote:
>
> Personally, I don't want them in D. If you have enough 
> arguments that it matters, then the function probably has too 
> many parameters or too many similar parameters. And as a 
> library writer, I don't want to have the parameter names be 
> part of the API. There are already enough problems getting the 
> type and function names right without having to worry about 
> bikeshedding over parameter names as well, and if we had named 
> arguments, then you couldn't change parameter names without 
> breaking code. It also wouldn't play well with separate 
> compilation unless the parameter names were mangled into the 
> function names, and symbol names in D are already too often too 
> long due to idioms like Voldemort types creating really long 
> symbol names. Recent work on the compiler has reduced that 
> problem, but adding more information to mangled names would 
> definitely not help.
>
> - Jonathan M Davis

Some good points. I realized that most of the languages that have 
named parameters are dynamically typed ones (Python/R) or ones 
with VMs (C#/Scala). Fortran has named parameters and function 
overloading, but I think it's a little quirky and not like C++ 
and D as far as I can tell.


More information about the Digitalmars-d mailing list