* 建议从翻译上调转了一下英文原著解释中的因果顺序
英文原著:
> Notice the use of the closure: the current i, xi are passed to the closure as parameters, masking the i, xi variables from the outer for-loop. This allows each goroutine to have its own copy of i, xi; otherwise, the next iteration of the for-loop would update i, xi in all goroutines. On the other hand, the res slice is not passed to the closure, since each goroutine does not need a separate copy of it. The res slice is part of the closure’s environment but is not a parameter
原译文:
>注意闭合:i、xi 都是作为参数传入闭合函数的,从外层循环中隐藏了变量 i 和 xi。让每个协程有一份 i 和 xi 的拷贝;另外,for 循环的下一次迭代会更新所有协程中 i 和 xi 的值。切片 res 没有传入闭合函数,因为协程不需要单独拷贝一份。切片 res 也在闭合函数中但并不是参数。
我的建议:
>注意上述代码中闭合函数的用法:`i`、`xi` 都是作为参数传入闭合函数的,这一做法使得每个协程有一份 `i` 和 `xi` 的拷贝,从而向闭合函数内部隐藏了外层循环中的变量 `i` 和 `xi`;否则,for 循环的下一次迭代会更新所有协程中 `i` 和 `xi` 的值。另一方面,切片 `res` 没有传入闭合函数,因为协程不需要`res`的单独拷贝。切片 `res` 也在闭合函数中但并不是参数。
* 增加了译者注和一些用词调整
the original words are :
A channel type may be annotated to specify that it may only send or only receive in certain code:
var send_only chan<- int // channel can only receive data
var recv_only <-chan int // channel can only send data
* update "tw-way pipe" to "tow-way pipe"
update "tw-way pipe" to "tow-way pipe"
* update "tw-way pipe" to "two-way pipe"
update "tw-way pipe" to "two-way pipe" and not "tow....." lol~~