Saturday, 28 February 2015

Is it possible to use XML syntax to create instance of a class by Scala macro?



Scala has powerful macro support, but I've never used that. I just wondering is it possible: use XML synctax to create instance of a class by Scala macro?


Say I have defined a class:



class User(name:String, age:Int)


Then I want to initialise it this way:



val user = macroHere(<User name="Freewind" age={100} />)


Is it possible?


No comments:

Post a Comment