8000 fixes suggested by Eugene Yokota · rssh/scala.github.com@9b65fb8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9b65fb8

Browse files
committed
fixes suggested by Eugene Yokota
See scala@71e0cdd
1 parent dde579a commit 9b65fb8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

overviews/macros/overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ It's customary to import `c.universe._`, because it includes a lot of routinely
123123
First of all, the macro needs to parse the provided format string.
124124
Macros run during the compile-time, so they operate on trees, not on values.
125125
This means that the format parameter of the `printf` macro will be a compile-time literal, not an object of type `java.lang.String`.
126-
This also means that the code below won't work for `printf(get_format(), ...)`, because in that case `format` won't be a string literal, but rather an AST that represents addition of two string literals. Adjusting the macro to work for arbitrary expressions is left as an exercise for the reader.
126+
This also means that the code below won't work for `printf(get_format(), ...)`, because in that case `format` won't be a string literal, but rather an AST that represents a function application. Adjusting the macro to work for arbitrary expressions is left as an exercise for the reader.
127127

128128
val Literal(Constant(s_format: String)) = format.tree
129129

130130
Typical macros (and this macro is not an exception) need to create ASTs (abstract syntax trees) which represent Scala code.
131131
To learn more about generation of Scala code, take a look at [the overview of reflection](http://docs.scala-lang.org/overviews/reflection/overview.html). Along with creating ASTs the code provided below also manipulates types.
132-
Note how we get a hold of Scala types that correspond to `Int and String`.
132+
Note how we get a hold of Scala types that correspond to `Int` and `String`.
133133
Reflection overview linked above covers type manipulations in detail.
134134
The final step of code generation combines all the generated code into a `Block`.
135135
Note the call to `reify`, which provides a shortcut for creating ASTs.

0 commit comments

Comments
 (0)
0