Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
LSUG Macro from Feb'13 dojo
package lsug
import scala.language.experimental.macros
import scala.reflect.macros.Context
object Debug {
def error(s:String) = macro error_impl
def error_impl(c: Context)(s: c.Expr[String]): c.Expr[Unit] = {
import c.universe._
val debug = System.getProperty("BOB", "false")
val x = if(debug.equals("true")) reify(println("ERR: " + s.splice)).tree else reify(println("")).tree
println(x)
c.Expr[Unit](Block(x))
}
}
------
package lsug
object Main extends App {
println( "Hello")
Debug.error("This is an error" )
println("End ")
}
@binarytemple

import c.universe._ .... was missing this, without import universe from context... no cheeze!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.