Java表达式树 [英] Java Expression Trees

查看:140
本文介绍了Java表达式树的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有 .net 的表达式树为 JVM 提供LINQ?我想在 Scala 中实现一些类似LINQ的代码结构,我想知道是否还要滚动我自己的表达式树库。

Is there an equivalent of .net's Expression Trees that underly LINQ for the JVM? I would like to implement some LINQ like code structures in Scala and I am wondering if I have to roll my own expression tree library also.

更新:
我对linq等价物本身不感兴趣。 .net有一大组表达式树工具,可以很容易地在运行时动态编译代码,可以从代码中调用它。我想进行的项目与数据库无关。表达式树提供了一种简单的方法来描述对数据进行操作的代码。

Update: I am not interested in a linq equivalent itself. .net has a large set of expression tree tools that make it easy to dynamically compile code at runtime can have it be callable from your code. The project I want to undertake has no relation to databases. Expression tree's provide an easy way to describe code that operates on data.

如果没有库我的其他选项我认为是创建一个发出字节代码的库。

If there is no library my other option I think is to create one that emits byte code.

推荐答案

从2.10开始,Scala有了宏,它允许您在编译时访问其参数的抽象语法树: http://scalamacros.org/ 。以下是一些使用示例,包括LINQ草图: http:// scalamacros。 org / paperstalks / 2013-12-02-WhatAreMacrosGoodFor.pdf

Since 2.10, Scala has macros, which give you access to abstract syntax trees of their arguments at compile-time: http://scalamacros.org/. Here are some examples of their usage including a sketch of LINQ: http://scalamacros.org/paperstalks/2013-12-02-WhatAreMacrosGoodFor.pdf.

这篇关于Java表达式树的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆