8000 TypeTag => WeakTypeTag in the macro guide by xeno-by · Pull Request #184 · scala/docs.scala-lang · GitHub
[go: up one dir, main page]

Skip to content

TypeTag => WeakTypeTag in the macro guide #184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions overviews/macros/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ or with `-language:experimental.macros` (providing a compiler switch) on per-com

### Generic macros

Macro definitions and macro implementations may both be generic. If a macro implementation has type parameters, actual type arguments must be given explicitly in the macro definition’s body. Type parameters in an implementation may come with `TypeTag` context bounds. In that case the corresponding type tags describing the actual type arguments instantiated at the application site will be passed along when the macro is expanded.
Macro definitions and macro implementations may both be generic. If a macro implementation has type parameters, actual type arguments must be given explicitly in the macro definition’s body. Type parameters in an implementation may come with `WeakTypeTag` context bounds. In that case the corresponding type tags describing the actual type arguments instantiated at the application site will be passed along when the macro is expanded.

The following code snippet declares a macro definition `Queryable.map` that references a macro implementation `QImpl.map`:

Expand All @@ -83,7 +83,7 @@ The following code snippet declares a macro definition `Queryable.map` that refe
}

object QImpl {
def map[T: c.TypeTag, U: c.TypeTag]
def map[T: c.WeakTypeTag, U: c.WeakTypeTag]
(c: Context)
(p: c.Expr[T => U]): c.Expr[Queryable[U]] = ...
}
Expand All @@ -95,7 +95,7 @@ Now consider a value `q` of type `Queryable[String]` and a macro call
The call is expanded to the following reflective macro invocation

QImpl.map(c)(<[ s => s.length ]>)
(implicitly[TypeTag[String]], implicitly[TypeTag[Int]])
(implicitly[WeakTypeTag[String]], implicitly[WeakTypeTag[Int]])

## A complete example

Expand Down
0