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
import scala.reflect.api._ | |
import scala.reflect.runtime._ | |
import scala.reflect.runtime.Mirror._ | |
object Pimps { | |
implicit def pimp(str:String) = new { | |
def test = println("hello") | |
} | |
} |
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
class ListBuilder extends Dynamic { | |
private var res = List[String]() | |
def applyDynamic(method: String)(args: Any*) = { | |
val argString = if (args.length>0) "(" + args.mkString(" ") + ")" else "" | |
res = method + argString :: res | |
this | |
} | |
def result = res.reverse |
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
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 |