I wonder if this can be done with scala macros
Consider this method:
def doSomething(filter: Item => Boolean) = ...
class Item(properties: Map[String, String]) extends Dynamic {
def selectDynamic(name:String): String = {
properties.getOrElse(name, "")
}
def updateDynamic(name: String)(value: String): Unit = {
addProperty(name, value)
}
}
And this usage
doSomething(x=> x.foo == "X" && x.bar == "Y" || x.baz.nonEmpty)
What I'd like to do is to simplify it (I'm writing a DSL for people who don't really use scala much) to this:
doSomething(foo == "X" && bar == "Y" || baz.nonEmpty)
My assumption is that even with Scala macros this might be impossible, or is it?
If so, where do I start? I assume this is not a simplistic macro...