4

The documentation of scala macro is very hard to understand, so I think it must have some background knowledge if one wants to use it in real case.

And I ask help for what these knowledge are.

c.Expr[Unit](Block(treesWithSeparators.toList, Literal(Constant(()))))

it is a code snippet of macro, and there are little info available for what Block means, and other similar terms. It is hard to go deep in if these key points lost.

So if anyone knows where exists a more detailed documentation or tutorial, please tell me, thanks:)

user1453345
  • 338
  • 2
  • 10

1 Answers1

2

It is hard to go deep in if these key points lost.

Yes that is true but it is good that not everyone can get a way into macros. They are a powerful feature and users that don't understand them fully should not use them.

Diving into macros requires a lot of self learning, there is no easy way to learn how they work and how to work with them.

Nevertheless there is already a lot of useful documentation out there. For example this question wants to know how to understand the AST: Where can I learn about constructing AST's for Scala macros?

This question on the other side gives some value on how to work with reify: What's the easiest way to use reify (get an AST of) an expression in Scala?

On docs.scala-lang.org there is an excellent overview available that describes what macros can do and what not. The official homepage also contains lots of useful information.

And reading further questions here on StackOverflow, looking at source code on GitHub or searching the web for blog posts on macros shouldn't be that difficult.

For the beginning this should be enough to find a way into macro hell.

Community
  • 1
  • 1
kiritsuku
  • 52,967
  • 18
  • 114
  • 136
  • 1
    I would like to add the scala reflection [overview](http://docs.scala-lang.org/overviews/reflection/overview.html), which covers [Symbols, Trees and Types](http://docs.scala-lang.org/overviews/reflection/symbols-trees-types.html). That section may help to understand what `Block` means. – neutropolis May 02 '13 at 13:05