Search code examples
scaladebuggingmacrosscala-macrosstringification

Is there a macros to see my code in runtime?


For debugging purposes, I want to print the passed argument, like

def myfunc(arg: MyType) = println(str_macro(arg) + " = " + arg)

I know, I can define mine own. But, the thing seems to be standard. Is is supplied by standard libs?


Solution

  • I don't think there is one in the standard library, but see https://github.com/adamw/scala-macro-debug and https://github.com/vn971/macro-format (you can also do show(reify(arg).tree)). Note that in this case, as 0__ says, the code for arg is going to be just arg!