Created
May 18, 2014 13:44
-
-
Save yanns/b0af896bf342d07bb5c2 to your computer and use it in GitHub Desktop.
expire with scala macros
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
scala> import scala.reflect.macros.blackbox.Context | |
import scala.reflect.macros.blackbox.Context | |
scala> def expire_impl(c: Context)(): c.Expr[Unit] = { | |
| c.error(c.enclosingPosition, "has expired") | |
| c.literalUnit | |
| } | |
<console>:10: warning: method literalUnit in trait ExprUtils is deprecated: Use quasiquotes instead | |
c.literalUnit | |
^ | |
expire_impl: (c: scala.reflect.macros.blackbox.Context)()c.Expr[Unit] | |
scala> import scala.language.experimental.macros | |
import scala.language.experimental.macros | |
scala> def expire(): Unit = macro expire_impl | |
defined term macro expire: ()Unit | |
scala> expire() | |
<console>:12: error: has expired | |
expire() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment