DIP 1030--Named Arguments--Community Review Round 1 Discussion
Adam D. Ruppe
destructionator at gmail.com
Thu Feb 13 02:00:37 UTC 2020
On Thursday, 13 February 2020 at 01:37:58 UTC, Walter Bright
wrote:
> static if (condition) pragma(msg, "Look, Ma!");
In this context, the condition there would be someone using the
parameter names. That's impossible to find in static if.
> Note that the compiler already uses a spell checker to look for
> close symbol matches.
A spell checker wouldn't necessarily catch a name change like
this since the distance between old and new name may be
significant. (e.g. ms to milliseconds has an edit distance of ...
what, 11?)
The current spell checker doesn't do it:
int milliseconds() { return 0; }
void main() {
int a = ms();
}
// wer.d(4): Error: undefined identifier ms
// note no suggestion given
But since the number of parameters is so limited, process of
elimination means even with a very large edit distance, it is
still probable that you meant one of the few missing parameters.
Like dmd will right now suggest:
wer.d(4): Error: function wer.milliseconds(int ms) is not
callable using argument types ()
wer.d(4): missing argument for parameter #1: int ms
So a natural extension of this could be
given named argument `milliseconds` does not match any
parameter
missing argument for parameter #1: int ms
And just those two messages next to each other, spell check or
no, would probably clue the user in. I doubt this will even need
additional code, but nevertheless, given the importance of good
error messages to user productivity, I think all DIPs ought to
have a section on diagnostics and any implementation should
ensure it is addressed one way or another.
More information about the Digitalmars-d
mailing list