BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Lambda Syntax Survey

Lambda Syntax Survey

The lambda syntax is under discussion again at lambda-dev mail list, but this time, they're actively courting opinions.

The “strawman” syntax provided a temporary means to discuss the aspects of the implementation and details of how lambda and type inference would work in the Java language, but it was never intended as a permanent syntax. Now, four separate syntax variations have been proposed:

  • Strawman: #(arglist)(expr) and #(arglist){statements}
  • BGGA: { args -> statements }
  • SotL: #{ args -> statements}
  • Redmond: (args) -> { statements }

The poll also provides what using real-life expressions might be like with the above syntaxes:

Example of Strawman:
   list.filter( #(Foo t)(t.length() > 3) )
       .map( #(Foo t)(t.barCount) )
       .max();

Example of BGGA:
   list.filter( { Foo t -> t.length() > 3 } )
       .map( { Foo t -> t.barCount } )
       .max();

Example of SotL:
   list.filter(#{ Foo t -> t.length() > 3 } )
       .map(#{ Foo t -> t.barCount } )
       .max();

Example of Redmond:
   list.filter((Foo t) -> { t.length() > 3 } )
       .map((Foo t) -> { t.barCount } )
       .max();

Please see the original post at the lambda-dev mail list for more details on the proposals, and for how to respond to the survey.

Rate this Article

Adoption
Style

BT