Skip to content

Instantly share code, notes, and snippets.

@takezoe
Created April 26, 2012 18:25
Show Gist options
  • Save takezoe/2501656 to your computer and use it in GitHub Desktop.
Save takezoe/2501656 to your computer and use it in GitHub Desktop.
Macro Example in scala-2.10.0-20120419
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)
}
}
@takezoe
Copy link
Author

takezoe commented Apr 30, 2012

2.10 M3で動くように修正してみた。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment