DIP 1030--Named Arguments--Community Review Round 1 Discussion
SashaGreat
s at g.com
Wed Feb 12 19:44:52 UTC 2020
On Wednesday, 12 February 2020 at 07:42:32 UTC, aliak wrote:
> Named arguments is the difference between spending 1 second
> looking at this:
>
> makeWindow(x: 67, y: 98, width: 100, height: 100)
>
> Or taking about 1 to 5 minutes depending on how easy
> documentation is to find, and how bored you are to figure out
> what this is doing:
>
> makeWindow(67, 98, 100, 100)
You're using an example in favor of a point, because it's hard to
someone use constants for this kind of thing for a production
code, at least for obvious reasons it shouldn't.
Now let's compare:
> makeWindow(x: 67, y: 98, width: 100, height: 100)
With:
makeWindow(x, y, width, height);
Of course 'x', 'y', 'width' and 'height' are variables defined
elsewhere, but it's less noisy.
Now to be honest I would prefer for this particular function to
use a struct like "myWindow" to define the coordinates:
makeWindow(myWindow);
I barely use name parameters for languages that support and to be
honest I barely see than in other codes.
IDE are pretty much advanced these days, and if I need to check
out at least in VS it shows me everything that I need about the
arguments (Names, Types...).
Sasha.
More information about the Digitalmars-d
mailing list