Warning about single underscore identifier

Brian Goetz brian.goetz at oracle.com
Wed Jul 31 11:52:32 PDT 2013

Yes, we are "reclaiming" the syntactic real estate of "_" from the space of identifiers for use in future language features.  However, because there are existing programs that might use it, it is a warning for identifiers that occur in existing syntactic positions for 8, and an error for lambda formals (since there is no existing code with lambdas.)  

Your suspicion is mostly right, except that we are certainly NOT going to do Scala's "wunderbar".  However, things it might be used for include things like "I don't want to give this variable a name" (such as catch parameters that are never used.)

On Jul 29, 2013, at 6:59 AM, Roel Spilker wrote:

> Hi all,
> If I compile a java program containing an identifier consisting of just a
> single underscore using the java 8 compiler, I get the following warning:
> warning: '_' used as an identifier
> (use of '_' as an identifier might not be supported in releases after Java
> SE 8)
> I suspect this is to allow for scalaesc parameters in lambdas.
> Can someone confirm my suspicion? Is this still relevant or is this a
> left-over from an early design? Is there a valid reason to not support '_'
> for all identifiers, or can it be only restricted for identifiers inside
> lambdas, and therefore guaranteed new code, to maintain backwards source
> compatibility.
> Roel

More information about the lambda-dev mailing list