DIP 88: Simple form of named parameters

Michel Fortin via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 24 05:16:35 PST 2016

On 2016-01-23 14:19:03 +0000, Jacob Carlborg <doob at me.com> said:

> This is mostly to prevent ugly hacks like Flag [1].
> http://wiki.dlang.org/DIP88
> [1] https://dlang.org/phobos/std_typecons.html#.Flag


This is somewhat similar to an experiment of mine from 5 years ago. My 
implementation was a bit of a hack, but my intent was to have a proof 
of concept done quickly. All arguments were considered optionally named 
in this experiment (there was no syntax to enable this in the function 
prototype). Also it didn't extend to templates arguments.

You can my discussion with Walter about it here:

Mixing reordering with overloading can become quite complicated. It's 
good that you leave that out at first. Adding reordering should be left 
as a separate task for later, if desired. Small steps.

Have you considered supporting separate variable names? Like this:

	void login(string username: name, string password:) {
		writeln(name ~ ": " ~ password);

where an identifier following the colon, if present, would be the name 
of the variable inside the function. That way you can use a shorter 
variable when it makes sense to do so. Or change the variable name 
without affecting the API.

Michel Fortin

More information about the Digitalmars-d mailing list