Create a gist now

Instantly share code, notes, and snippets.

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
package lsug
object Main extends App {
println( "Hello")
Debug.error("This is an error" )
println("End ")

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