Skip to content

Instantly share code, notes, and snippets.

@stephanos
Forked from takezoe/MacroSample.scala
Created October 20, 2012 09:44
Show Gist options
  • Save stephanos/3922811 to your computer and use it in GitHub Desktop.
Save stephanos/3922811 to your computer and use it in GitHub Desktop.
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