Skip to content

Simplify Chinese translation of Scala Tour: annotations.md #1210

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 2 commits into from
Nov 30, 2018

Conversation

realwunan
Copy link
Contributor

Simplify Chinese translation of Scala Tour: Annotations

@@ -13,3 +13,114 @@ language: zh-cn
next-page: default-parameter-values
previous-page: by-name-parameters
---

注解将元信息与定义相关联。 例如,方法之前的注解 `@deprecated` 会导致编译器在该方法被调用时打印警告信息。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

被调用 -> 被使用

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot.

```
这个程序可以编译,但编译器将打印一个警告信息: "there was one deprecation warning"。

注解子句适用于其后的第一个定义或声明。 在定义和声明之前可以有多个注解子句。 这些子句的顺序并不重要。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

适用于 --> 作用于?

子句?

这些子句 -> 这些注解

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot.



## 影响代码生成的注解
像 `@inline` 这样的注解会影响生成的代码(即你的 jar 文件可能与你没有使用注解时有不同的字节)。 内联表示在调用点插入被调用方法体中的代码。 生成的字节码更长,但有希望能运行得更快。 使用注解 `@inline` 并不能确保方法内联,但是当且仅当满足某些生成代码大小的启发式算法时,它会触发编译器执行此操作。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

但是当且仅当

会触发

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot.


### Java 注解 ###
在编写与 Java 互操作的 Scala 代码时,注解语法中存在一些差异需要注意。
**注意:** 确保你在使用 `-target:jvm-1.8` 选项时使用 Java 注解。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你在使用 开启 -target:jvm-1.8 选项

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot.

public class MyClass extends HisClass ...
```

Scala 在这方面提供了更强的灵活性
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

更强 -> 更大

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot.

Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @realwunan 🎉

@liufengyun liufengyun merged commit eba2f4c into scala:master Nov 30, 2018
@realwunan realwunan deleted the annotations branch November 30, 2018 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants