Skip to content
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

Release 1.3 #99

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "JuliaZH"
uuid = "652e05fd-ed22-5b6c-bf99-44e63a676e5f"
version = "1.1.0"
version = "1.3.1"

[deps]
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Expand Down
4 changes: 2 additions & 2 deletions doc/src/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Julia 1.1 中文文档
# Julia 1.3 中文文档

欢迎来到 Julia 1.1 中文文档([PDF版本](https://raw.githubusercontent.com/JuliaCN/JuliaZH.jl/pdf/dev/Julia中文文档.pdf))!
欢迎来到 Julia 1.3 中文文档([PDF版本](https://raw.githubusercontent.com/JuliaCN/JuliaZH.jl/pdf/v1.3.1/Julia中文文档-1.3.1.pdf))!

请先阅读 [v1.0 正式发布博文](https://julialang.org/blog/2018/08/one-point-zero-zh_cn) 以获得对这门语言的总体概观。我们推荐刚刚开始学习 Julia 语言的朋友阅读中文社区提供的 [Julia入门指引](https://discourse.juliacn.com/t/topic/159),也推荐你使用[discourse](https://discourse.juliacn.com)对遇到的问题进行提问。

Expand Down
2 changes: 1 addition & 1 deletion zh_CN/doc/src/base/multi-threading.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Base.Threads.atomic_fence
Base.@threadcall
```

## 同步原始类型
## 同步基元

```@docs
Base.Threads.AbstractLock
Expand Down
2 changes: 1 addition & 1 deletion zh_CN/doc/src/devdocs/ast.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Julia 有两种代码的表现形式。
* `Expr`

Has a node type indicated by the `head` field, and an `args` field which is a `Vector{Any}` of
subexpressions.
子表达式
尽管表层 AST 中,几乎每个部分都是通过 `Expr` 表示的,中间表现形式只四用了很有限的 `Expr`,主要用于调动、条件分支 (`gotoifnot`) 和返回。
limited number of `Expr`s, mostly for calls, conditional branches (`gotoifnot`), and returns.

Expand Down
2 changes: 1 addition & 1 deletion zh_CN/doc/src/devdocs/valgrind.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Using Valgrind with Julia
# 在Julia中使用Valgrind

[Valgrind](http://valgrind.org/) is a tool for memory debugging, memory leak detection, and profiling.
This section describes things to keep in mind when using Valgrind to debug memory issues with
Expand Down
6 changes: 5 additions & 1 deletion zh_CN/doc/src/manual/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,11 @@ julia> broadcast(+, a, b)

类似 `.+` 和 `.*` 的[点运算符](@ref man-dot-operators) 等同于 `broadcast` 调用(除了它们融合两种操作,如下所述)。还有一个 [`broadcast!`](@ref) 函数来指定一个显式目标(也可以通过 `.=` 赋值以融合的方式访问它)。事实上,`f.(args...)` 等价于 `broadcast(f, args...)`,并为广播任何函数提供了方便的语法([dot syntax](@ref man-vectorized))。嵌套的「点调用」`f.(...)`(包括调用 `.+` 等)[自动融合](@ref man-dot-operators)到单个 `broadcast` 调用。

另外,[`broadcast`](@ref) 并不局限于数组(参见函数文档),对于元组依然有效。对于其他非数组,元组或引用 [`Ref`](@ref)(除了指针 [`Ptr`](@ref)) 的参数,视作“标量”。
Additionally, [`broadcast`](@ref) is not limited to arrays (see the function documentation);
it also handles scalars, tuples and other collections. By default, only some argument types are
considered scalars, including (but not limited to) `Number`s, `String`s, `Symbol`s, `Type`s, `Function`s
and some common singletons like `missing` and `nothing`. All other arguments are
iterated over or indexed into elementwise.

```jldoctest
julia> convert.(Float32, [1, 2])
Expand Down
293 changes: 167 additions & 126 deletions zh_CN/doc/src/manual/calling-c-and-fortran-code.md

Large diffs are not rendered by default.

90 changes: 46 additions & 44 deletions zh_CN/doc/src/manual/code-loading.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions zh_CN/doc/src/manual/complex-and-rational-numbers.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Julia 语言包含了预定义的复数和有理数类型,并且支持它们

## 复数

在Julia中,全局常量 [`im`](@ref) 被绑定到复数 *i*,表示 -1 的主平方根(不应使用数学家习惯的 `i` 或工程师习惯的 `j` 来表示此全局常量,因为它们是非常常用的索引变量名。)由于 Julia 允许数值字面量[作为系数与标识符并置](@ref man-numeric-literal-coefficients),这种绑定就足够为复数提供很方便的语法,类似于传统的数学记法:
在Julia中,全局常量 [`im`](@ref) 被绑定到复数 *i*,表示 -1 的主平方根(不应使用数学家习惯的 `i` 或工程师习惯的 `j` 来表示此全局常量,因为它们是非常常用的索引变量名)。由于 Julia 允许数值字面量[作为系数与标识符并置](@ref man-numeric-literal-coefficients),这种绑定就足够为复数提供很方便的语法,类似于传统的数学记法:

```jldoctest
julia> 1+2im
Expand Down Expand Up @@ -76,7 +76,7 @@ julia> 1 + 3/4im
1.0 - 0.75im
```

注意 `3/4im == 3/(4*im) == -(3/4*im)`,因为文本系数比除法的优先级更高
注意 `3/4im == 3/(4*im) == -(3/4*im)`,因为系数比除法的优先级更高

Julia 提供了一些操作复数的标准函数:

Expand All @@ -103,7 +103,7 @@ julia> angle(1 + 2im) # 以弧度为单位的相位角
1.1071487177940904
```

按照惯例,复数的绝对值([`abs`](@ref))是从零点到它的距离。[`abs2`](@ref) 给出绝对值的平方,作用于复数上时非常有用,因为它避免了取平方根。[`angle`](@ref) 返回以弧度为单位的相位角(这也被称为辐角函数)。所有其它的[初等函数](@ref)在复数上也都有完整的定义:
按照惯例,复数的绝对值([`abs`](@ref))是从零点到它的距离。[`abs2`](@ref) 给出绝对值的平方,作用于复数上时非常有用,因为它避免了取平方根。[`angle`](@ref) 返回以弧度为单位的相位角(也被称为辐角函数)。所有其它的[初等函数](@ref)在复数上也都有完整的定义:

```jldoctest
julia> sqrt(1im)
Expand Down
6 changes: 3 additions & 3 deletions zh_CN/doc/src/manual/constructors.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ Point{Int64}(1, 2)
julia> Point(1.0,2.5) ## 隐式的 T ##
Point{Float64}(1.0, 2.5)

julia> Point(1,2.5) ## 隐式的 T ##
julia> Point(1,2.5) ## implicit T ##
ERROR: MethodError: no method matching Point(::Int64, ::Float64)
Closest candidates are:
Point(::T<:Real, ::T<:Real) where T<:Real at none:2
Point(::T, ::T) where T<:Real at none:2

julia> Point{Int64}(1, 2) ## 显式的 T ##
Point{Int64}(1, 2)
Expand Down Expand Up @@ -279,7 +279,7 @@ Point{Float64}
julia> Point(1.5,2)
ERROR: MethodError: no method matching Point(::Float64, ::Int64)
Closest candidates are:
Point(::T<:Real, !Matched::T<:Real) where T<:Real at none:1
Point(::T, !Matched::T) where T<:Real at none:1
```

如果你想要找到一种方法可以使类似的调用都可以正常工作,请参阅[类型转换与类型提升](@ref conversion-and-promotion)。这里稍稍“剧透”一下,我们可以利用下面的这个外部构造函数来满足需求,无论输入参数的类型如何,它都可以触发通用的 `Point` 构造函数:
Expand Down
29 changes: 15 additions & 14 deletions zh_CN/doc/src/manual/control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ julia> for i = 1:2, j = 3:4
| [`ArgumentError`](@ref) |
| [`BoundsError`](@ref) |
| [`CompositeException`](@ref) |
| [`DimensionMismatch`](@ref) |
| [`DivideError`](@ref) |
| [`DomainError`](@ref) |
| [`EOFError`](@ref) |
Expand Down Expand Up @@ -629,22 +630,22 @@ Stacktrace:

### `try/catch` 语句

The `try/catch` statement allows for `Exception`s to be tested for, and for the
graceful handling of things that may ordinarily break your application. For example,
in the below code the function for square root would normally throw an exception. By
placing a `try/catch` block around it we can mitigate that here. You may choose how
you wish to handle this exception, whether logging it, return a placeholder value or
as in the case below where we just printed out a statement. One thing to think about
when deciding how to handle unexpected situations is that using a `try/catch` block is
much slower than using conditional branching to handle those situations.
Below there are more examples of handling exceptions with a `try/catch` block:
通过 `try / catch` 语句,可以测试 Exception
优雅处理可能会破坏应用程序的事情。 例如,
在下面的代码中,平方根函数会引发异常。 通过
在其周围放置 `try / catch` 块可以缓解。 您可以选择如何
处理此异常,无论是记录它,返回占位符值还是
就像下面仅打印一句话。 要注意的是
在决定如何处理异常时,使用`try / catch`
比使用条件分支处理要慢得多。
以下是使用` try / catch` 块处理异常的更多示例:

```jldoctest
julia> try
sqrt("ten")
catch e
println("You should have entered a numeric value")
end
sqrt("ten")
catch e
println("You should have entered a numeric value")
end
You should have entered a numeric value
```

Expand Down Expand Up @@ -821,6 +822,6 @@ taskHdl = @task mytask(7)

| 符号 | 含义 |
|:----------- |:-------------------------------------------------- |
| `:runnable` | Currently running, or able to run |
| `:runnable` | 正在运行,或者可以被切换到 |
| `:done` | 成功结束执行 |
| `:failed` | 以一个没被捕获的异常结束 |
24 changes: 19 additions & 5 deletions zh_CN/doc/src/manual/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ search: * .*

## 进阶用法

`@doc`宏在叫做`META`的每个模块的字典中连接他的第一个和第二个参数。默认地,文档希望是用Markdown写成,并且`doc"""`字符串宏简单地创造一个代表了Markdown内容的对象。在未来,有可能支持更多的进阶功能比如考虑到相关的图像或者链接路径。
The `@doc` macro associates its first argument with its second in a per-module dictionary called
`META`.

为了让写文档更加简单,语法分析器对宏名`@doc`特殊对待:如果`@doc`的调用只有一个参数,但是在下一行出现了另外一个表达式,那么这个表达式就会追加为宏的参数。所以接下来的语法会被分析成`@doc`的2个参数的调用:

Expand All @@ -262,7 +263,7 @@ search: * .*
f(x) = x
```

这就让使用任意对象(这里指的是`原始`字符串)作为docstring变得简单。
This makes it possible to use expressions other than normal string literals (such as the `raw""` string macro) as a docstring.

当`@doc`宏(或者`doc`函数)用作抽取文档时,他会在所有的`META`字典寻找与对象相关的元数据并且返回。返回的对象(例如一些Markdown内容)会默认智能地显示。这个设计也让以编程方法使用文档系统变得容易;例如,在一个函数的不同版本中重用文档:

Expand Down Expand Up @@ -313,11 +314,24 @@ y = MyType("y")

## 语法指南

对于所有的可写文档的Julia语法的总览。
A comprehensive overview of all documentable Julia syntax.
In the following examples `"..."` is used to illustrate an arbitrary docstring.

在下述例子中`"..."`用来表示任意的docstring。
### `$` and `\` characters

`doc""`只应用在如下情况下:docstring包含不应被Julia分析的`$`或者`\`字符,比如LaTeX语法;Julia源码中包含插值。
The `$` and `\` characters are still parsed as string interpolation or start of an escape sequence
in docstrings too. The `raw""` string macro together with the `@doc` macro can be used to avoid
having to escape them. This is handy when the docstrings include LaTeX or Julia source code examples
containing interpolation:

````julia
@doc raw"""
```math
\LaTeX
```
"""
function f end
````

### 函数与方法

Expand Down
1 change: 0 additions & 1 deletion zh_CN/doc/src/manual/embedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ We start by opening Visual Studio and creating a new Console Application project
header file, add the following lines at the end:

```c
#define JULIA_ENABLE_THREADING
#include <julia.h>
```

Expand Down
15 changes: 8 additions & 7 deletions zh_CN/doc/src/manual/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ Julia 使用的环境变量通常以 `JULIA` 开头。如果调用 [`Interactive

!!! note

某些变量需要在 Julia 启动之前设置,比如 `JULIA_NUM_THREADS` 和 `JULIA_PROJECT`,因为在启动过程中将这些变量添加到 `~/.julia/config/startup.jl` 中为时已晚。在 Bash 中,环境变量可以手动设置,这可通过在 Julia 启动前运行诸如 `export JULIA_NUM_THREADS=4` 的命令,亦可通过向 `-/.bashrc` 或 `~/.bash_profile` 添加相同命令来在 Bash 每次启动时设置该变量。
Some variables, such as `JULIA_NUM_THREADS` and `JULIA_PROJECT`, need to be set before Julia
starts, therefore adding these to `~/.julia/config/startup.jl` is too late in the startup process.
In Bash, environment variables can either be set manually by running, e.g.,
`export JULIA_NUM_THREADS=4` before starting Julia, or by adding the same command to
`~/.bashrc` or `~/.bash_profile` to set the variable each time Bash is started.

## 文件位置

Expand Down Expand Up @@ -95,8 +99,8 @@ environment variable or if it must have a value, set it to the string `:`.
The `JULIA_DEPOT_PATH` environment variable is used to populate the global Julia
[`DEPOT_PATH`](@ref) variable, which controls where the package manager, as well
as Julia's code loading mechanisms, look for package registries, installed
packages, named environments, repo clones, cached compiled package images, and
configuration files.
packages, named environments, repo clones, cached compiled package images,
configuration files, and the default location of the REPL's history file.

Unlike the shell `PATH` variable but similar to `JULIA_LOAD_PATH`, empty entries in
`JULIA_DEPOT_PATH` are expanded to the default value of `DEPOT_PATH`. This allows
Expand All @@ -121,7 +125,7 @@ or if it must have a value, set it to the string `:`.
REPL 历史文件中 `REPL.find_hist_file()` 的绝对路径。如果没有设置 `$JULIA_HISTORY`,那么 `REPL.find_hist_file()` 默认为

```
$HOME/.julia/logs/repl_history.jl
$(DEPOT_PATH[1])/logs/repl_history.jl
```

### `JULIA_PKGRESOLVE_ACCURACY`
Expand Down Expand Up @@ -262,7 +266,4 @@ Julia 用来执行外部命令的 shell 的绝对路径(通过 `Base.repl_cmd(

传递给 LLVM 后端的参数。

### `JULIA_DEBUG_LOADING`

如果设置,那么 Julia 会打印在 [`Base.require`](@ref) 加载过程中的有关缓存的详细信息。

Loading