Reputation: 779
Microsoft Roslyn - compiler as a service is a nice addition to the .NET stack; I was looking for something similar in the Java world. I believe Scala has something similar in the form of compiler plugins but not sure how flexible it is.
The problem I am trying to solve in the Java world is allowing users to write some custom syntax and internally it would get re-wired into a different syntax.
Upvotes: 5
Views: 2027
Reputation: 40461
Scala will have support for macros in the next release (2.10). You can already play with the milestone releases to check how it works. Basically, they allow to modify AST at compile time. So you can rewrite any piece of Scala in another piece of scala. Check the scalamacros website for examples and doc.
If you want to compile Scala source at runtime, you can look for Eval
in the twitter/util project.
Upvotes: 2
Reputation: 18542
I've never used Microsoft Roslyn, so I'm not sure about what it provides. But if what you want is to be able to compile classes at runtime, you should look at the JavaCompiler API which has been a part of standard Java since Java SE 6. If that doesn't suit your needs you should probably take a look at Eclipse's ASTParser.
Upvotes: 3