Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8196589

add compiler support for local-variable syntax for lambda parameters

    XMLWordPrintable

Details

    • CSR
    • Resolution: Approved
    • P3
    • 11
    • tools
    • None
    • minimal
    • Language construct

    Description

      Summary

      JEP 323: Allow var to be used when declaring the formal parameters of implicitly typed lambda expressions

      Problem

      The syntax of a formal parameter declaration in an implicitly typed lambda expression is not aligned with the syntax of a local variable declaration. See JEP 323 for more discussion.

      Solution

      The parser will allow the formal parameters of an implicitly typed lambda expression to be denoted with var. A var applied to a formal parameter of an implicitly typed lambda expression will be ignored and the inferred type will be exactly the same as not using var at all. Like the distinction between implicit and explicit lambdas itself, using this syntax is all-or-nothing; either all parameters must be declared with var, or none.

      Specification

      Proposed changes to the Java Language Specification are attached.

      Attachments

        Issue Links

          Activity

            People

              dlsmith Dan Smith
              vromero Vicente Arturo Romero Zaldivar
              Brian Goetz
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: