Lambdas v.008, usable Now! Forward compatible with Java 1.7

Llewellyn Falco isidore at setgame.com
Sat Jan 8 01:54:05 PST 2011


Hey everyone.
I wanted to do more to actually get everyone using lambdas more, and
it occurred to me I could make my current java 6 implementation forwards
compatible with the proposed java 7 implementation.

What this mean to you:

You can download the lambda v.008 jar (72k) and start writing and using
lambdas today, in your *production *code, and you can take those functions &
utilities and play with them against the current java 7 spec.
Hopefully this triger a bunch more examples and consideration to help make
lambdas even better when they are actually released.
Enjoy,
Llewellyn Falco
Java Lambda Download
https://sourceforge.net/projects/approvaltests/files/Lambda.Java/

(the following is the top part of my blog, you can find the rest of it here
: http://blog.approvaltests.com/2011/01/lambdas-18-usable-now-forward.html
  )

I released Java Lambdas v.008 which allows for forward compatibility with
the new Lambda implementation coming down the pike for Java 7

The idea is this. Create methods that receive a Function[0-9] or
Action[0-9], and then create that lambda with either my current lambda
implementation F[0-9] or A[0-9] now, or when Java 1.7 finally implements
lambdas in the syntax, simply convert them to that official syntax #{a->a}

Let's look at an example:
Get all the people over 35 years old
To do this, we want to use the method

Query.*where*(List, Function1<T, Boolean>)


S1 implements Function1, so we can write the following in Java 1.6

 List<Person> people =
      Query.*where*(*getStudents()*, *new* S1<Person>(a){{ret(a.getAge() *>*
 35);}});


However, once Java 1.7 releases the official Lambdas, we can convert this to
the much simpler call


List<Person> people =
      Query.*where*(*getStudents()*,#{a *->* a.getAge() *>* 35});



Because Function1 is a SAM interface (single abstract method)


More information about the lambda-dev mailing list