I'm looking for a Java macro language that provides for convenient ways of doing closures (that compile to anonymous inner classes) and list comprehension (that compiles down to basic java loops).

An example of the kind of thing I'm looking for would be Xtend2 http://www.eclipse.org/Xtext/#xtend2

But I want something for general purpose programming (Xtend2 is very specific DSL for Xtext and has a ton of dependencies). Maybe even something that would let me define multiple classes in a single file (which would then get split up into two separate files by the pre-processor).

Does anything like this exist?

Edited to add: I'm doing Android development so any alternatives have to generate either valid Java source or the byte code has to be compatible with the dalvik recompiler.

有帮助吗?

解决方案

Mmm, there used to be the JSE, which was tremendous fun, back in the day.

Mirah is cool, but not ready for primetime, IMO.

You can do a lot with smart templating, although your source view is the Java.

There's a post on SO about using XTend on Android from a few days ago, too.

其他提示

Frege produces java source code.

I do not know whether dalvik would like it. (But I would be interested to hear ...) And, of course, you have some runtime library code.

That being said, there are a number of other projects that do closures etc. in java, for example: lambdaj

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top