Named arguments

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Oct 24 22:08:57 UTC 2017


On Tuesday, October 24, 2017 13:36:00 H. S. Teoh via Digitalmars-d wrote:
> On Tue, Oct 24, 2017 at 01:22:41PM -0600, Jonathan M Davis via
> > 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.
>
> [...]
>
> Nah.  Parameter names are a concept only necessary at compile-time.  All
> you need is to import the function declaration with the right parameter
> names, and on the caller's side the compiler will always emit the
> arguments in the right order.  So no need to mangle parameter names at
> all.

Except that things get a bit interesting with regards to stuff like .di
files. Without the parameter names being mangled in, it would be possible
for the parameter names in the .di files to not match the ones in the .d
files. It's possible for that now, but right now, it doesn't matter, whereas
with named arguments, it would matter. To some extent, you could probably
get away with it, because the code that compiles against the .di files
wouldn't normally be compiled against the .d files or vice versa, but it
means that switching whether you used the .di files or the .d files could
break code, whereas now, it wouldn't.

Now, .di files are kind of terrible to use anyway, but introducing named
arguments would just make them even more fragile if the parameter names
aren't part of the function's mangled name.

- Jonathan M Davis



More information about the Digitalmars-d mailing list