Unnamed variables and match-all patterns
Alex Buckley
alex.buckley at oracle.com
Thu Sep 8 22:32:42 UTC 2022
On 9/8/2022 5:22 AM, Brian Goetz wrote:
> 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.
A longstanding request is for method parameters that are implicitly
final, so that static analysis can point out dumb assignments to them in
the method body. I suspect a lot of requestors are actually thinking
about constructor parameters, where useless self-assignment (`firstName
= firstName;`) is a tripwire for Java beginners. Of course, record
classes sidestep the assignment boilerplate completely, but being able
to denote a constructor parameter as unusable, and therefore unused, and
therefore not contributory to the state of an object, feels like it has
some utility. This speaks to keeping an open mind about D, even if A is
the first step.
Alex
More information about the amber-spec-observers
mailing list