Created
January 6, 2013 09:39
-
-
Save markmarch/4466303 to your computer and use it in GitHub Desktop.
simple macro use case
This file contains hidden or 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 scala.language.experimental.macros | |
| import scala.reflect.macros.Context | |
| /** Trying out macros in Scala 2.10 */ | |
| object Macros { | |
| def compiledTime(): String = macro compiledTime_impl | |
| def compiledTime_impl(c: Context)(): c.Expr[String] = { | |
| import c.universe._ | |
| val date = c.Expr[String](Literal(Constant(new java.util.Date().toString))) | |
| reify("Compiled at:" + date.splice) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment