-
Notifications
You must be signed in to change notification settings - Fork 1k
[zh-cn]add reflect tags #1783
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
[zh-cn]add reflect tags #1783
Conversation
@jxnu-liguobin Thanks for the contribution! I can't review this myself so could you find someone who can? /cc @scala/docs-zh |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, LGTM 👍
Scala类型的完整类型描述符。例如,`TypeTag[List[String]]`包含所有类型信息,在本例中是类型`scala.List[String]`。 | ||
|
||
2. `scala.reflect.ClassTag`。 | ||
Scala类型的部分类型描述符。例如,`ClassTag[List[String]]`只包含已删除的类类型信息,在本例中为`scala.collection.immutable.List`。`ClassTag`只提供对类型的运行时类的访问。类似于`scala.reflect.ClassManifest`。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scala类型的部分类型描述符。例如,`ClassTag[List[String]]`只包含已删除的类类型信息,在本例中为`scala.collection.immutable.List`。`ClassTag`只提供对类型的运行时类的访问。类似于`scala.reflect.ClassManifest`。 | |
Scala类型的部分类型描述符。例如,`ClassTag[List[String]]`只包含已擦除、关于类的类型信息,在本例中为`scala.collection.immutable.List`。`ClassTag`只提供对类型的运行时类的访问,其类似于`scala.reflect.ClassManifest`。 |
|
||
### 使用类型为`TypeTag[T]`、`ClassTag[T]`或`WeakTypeTag[T]`的隐式参数 | ||
|
||
与`Manifest`一样,实际上可以 _请求_ 编译器生成`TypeTag`。这只需指定一个类型为`TypeTag[T]`的隐式 _票据_ 参数即可完成。如果编译器在隐式搜索期间找不到匹配的隐式值,它将自动生成一个`TypeTag[T]`。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
与`Manifest`一样,实际上可以 _请求_ 编译器生成`TypeTag`。这只需指定一个类型为`TypeTag[T]`的隐式 _票据_ 参数即可完成。如果编译器在隐式搜索期间找不到匹配的隐式值,它将自动生成一个`TypeTag[T]`。 | |
与`Manifest`一样,实际上可以 _请求_ 编译器生成`TypeTag`。这只需指定一个类型为`TypeTag[T]`的隐式 _例证_ 参数即可完成。如果编译器在隐式搜索期间找不到匹配的隐式值,它将自动生成一个`TypeTag[T]`。 |
/cc @scala/docs-zh evidence
的翻译我不晓得有没有标准的译法。我建议翻译为“例证”。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the original sentence? I'd say use 证据
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As with
Manifest
s, one can in effect request that the compiler generate a
TypeTag
. This is done by simply specifying an implicit evidence parameter
of typeTypeTag[T]
. If the compiler fails to find a matching implicit value
during implicit search, it will automatically generate aTypeTag[T]
.
In other words, it's using using the term evidence as a metaphor of typeclass instance. In Haskell for example this may come up as a phrase equality evidence. How would you say that in Chinese? I feel like (相等的)证据 fits better than others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“例证” has the connotation that it's an instance of possible proofs. But I agree 证据
might be easier to understand than inventing a new technical term.
I also think the |
thank you! |
This is a draft, any proposed changes will be resolved.