Meta-expression for Lambda (capturing Lambda as expressions tree)
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Mon Jun 13 14:29:24 UTC 2016
Hi Radoslaw,
this mailing list is for discussing the reference implementation of
Project Valhalla; I suggest you use a more general mailing list for the
discussion of your prototype e.g. compiler-dev at opendjk.java.net
Cheers
Maurizio
On 13/06/16 14:32, Radosław Smogura wrote:
> Dear all,
>
> I would like to propose as language extension lambda meta expression, with prototype, which can be found here [1].
>
> A meta expression (expression tree, like in C#, Linq) captures lambda in the syntax tree representing, very closely original source code. The expression can be retrieved at runtime and used to build new programs (typically queries) in order to pass those to external execution engines (SQL, noSQL). Ie, one can write
>
> MyTable.asStream().filter(r -> r.paymentDate == null),
>
> which can be converted to SQL
>
> SELECT * FROM my_table Where r.payment_date is null
>
> or to call micro service...
> GET /my_table?payment_date=null
>
> The possibility of retrieving lambda structure will:
> - increase contract between Java domain and non-Java word,
> - increase portability of quering code, by providing more unified queuing interface based on stream and Lambda expressions,
> - simplify developing due to unification of querying API among many libraries and solutions,
> - reduce amount of hardcoded values, like database columns, query parameters, etc.
>
> The prototype which I would like to present is based on JDK 9. With project Jigsaw java.expression module has to be added to class path (linked with JDK), as because of easy-of-development everything is in langtools. Right now it’s possible to store and retrieve simple lambda meta-expression and traverse it with Visitor API (ie. toString() makes it).
>
> Despite the fact that prototype is at very early stage and doesn’t allow capturing full language structure it presents one possible approach to storing and retrieving expression trees.
>
> Currently, there is product [2] supporting building JPA expressions from lambda. But as it uses automatic reverse engineering, it may not produce adequate results in all situations.
>
> Best regards,
> Radek Smogura
> [1] https://bitbucket.org/radoslaw_smogura/java-lambda-metaexpression-jdk9-langtools/
> [2] http://www.jinq.org/docs/queries.html
>
More information about the valhalla-dev
mailing list