JEP 213: Milling Project Coin
Benji Weber
javac at benjiweber.co.uk
Sat Oct 18 08:01:18 UTC 2014
Is it worth reconsidering? Underscore as a variable name has become
significantly more useful since the release of 8. For example
We can now do partial application.
Function<Integer, Integer> plusFive = Partially.apply(Math::addExact, _,
5);
int seven = plusFive.apply(2);
We can now do pattern matching.
args.match()
.when(arg("--help", _), arg -> this.printHelp(arg.value()))
.when(arg("--lang", _), arg -> this.setLanguage(arg.value()))
Of course we could use a different variable name other than underscore to
represent a wildcard, but underscore is already widely understood as a
placeholder in this context, due to its use in Scala, Haskell and others.
Removing _ means it will only be useful for what the language developers
have been able to think of/implement, rather than what any library
developers can implement, and restricted to the language release schedule.
--
benji
On 17 October 2014 20:36, Brian Goetz <brian.goetz at oracle.com> wrote:
> This is merely a follow-through on a decision that was made as part of
> JSR-335, Lambda Expressions for the Java Language. In 8, warnings were
> issued when such identifiers were used, that say "this will go away in 9."
> (Try it with an 8 build, you'll see.) This is merely the follow-through to
> that decision (since we couldn't do it all in one go in 8.)
>
> On 10/15/2014 9:05 PM, Rob Leland wrote:
>
>> Is there a JDK issue filed somewhere that discusses #4 Remove underscore
>> .... Since its sure to draw some push back.
>>
>> All other issues have such a reference.
>>
>> On Oct 15, 2014 8:56 PM, <mark.reinhold at oracle.com
>> <mailto:mark.reinhold at oracle.com>> wrote:
>>
>> New JEP Candidate: http://openjdk.java.net/jeps/213
>>
>> - Mark
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20141018/3c6ddf07/attachment-0001.html>
More information about the compiler-dev
mailing list