Unnamed variables and match-all patterns
Brian Goetz
brian.goetz at oracle.com
Thu Sep 8 12:22:22 UTC 2022
>
> I'm not sure it's so critical. To me, the main source of frustration
> is the necessity to think up a name that I won't use anyway. The
> second source is the fact that the code becomes noticeably longer when
> it includes unused names. Both problems are not so important for
> method parameters:
>
> - If you override or implement method, any IDE just copies names from
> the super-method for you, so you don't need to think.
> - Method declaration is already quite verbose. It contains @Override
> annotation, modifiers, types of all parameters and return type
> explicitly spelled, all of them could be quite long. Probably other
> annotations, throws and Javadoc. Saving few chars there would not help
> much. On the other hand, declaration doesn't contain logic, so people
> rarely stare at it trying to understand what's going on.
For the people who complain about this, I don't think it's about saving
a few characters in the declaration, as much as satisyfing static
analysis that complains about unused parameters. But I suspect that
many of these have already become lambdas (this happened most commonly
with anonymous classes previously). So I'm willing to do the experiment
of A first and see if we need to take the next step.
More information about the amber-spec-observers
mailing list