Created
April 26, 2012 18:25
-
-
Save takezoe/2501656 to your computer and use it in GitHub Desktop.
Macro Example in scala-2.10.0-20120419
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import language.experimental.macros | |
import scala.reflect.makro.Context | |
object MacroSample { | |
def compiledTime(): String = macro compiledTime_impl | |
def compiledTime_impl(c: Context)(): c.Expr[String] = { | |
import c.mirror._ | |
import c.reify | |
val date = Expr(Literal(Constant(new java.util.Date().toString))) | |
reify("Compiled Time: " + date.eval) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2.10 M3で動くように修正してみた。