Skip to content

Commit 42b8293

Browse files
committed
update swift 6 english
1 parent d79c265 commit 42b8293

19 files changed

+94
-96
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ We extend our heartfelt thanks to all our contributors. You can find the [list o
6565

6666
## 当前状态
6767

68-
- The Swift Programming Language 的最新英文版本。[最新提交: 11a2b29][11a2b29]
68+
- The Swift Programming Language 的最新英文版本。[最新提交: fe0121d][https://github.com/swiftlang/swift-book/commit/fe0121d1f2d86d6139c2b424d45a7889b82ff5e2]
6969
- 对应的简体中文翻译 (进行中和已归档):
7070
- Swift 6 beta (当前正在翻译)
7171
- Swift 5.x 及更早版本 (可在 [GitBook][legacy-documentations] 上阅读)

TSPL.docc/LanguageGuide/Concurrency.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -759,10 +759,10 @@ The code above makes several changes from the previous version:
759759
[`Task.isCancelled` instance]: https://developer.apple.com/documentation/swift/task/iscancelled-swift.property
760760

761761
For work that needs immediate notification of cancellation,
762-
use the [`Task.withTaskCancellationHandler(operation:onCancel:)`][] method.
762+
use the [`Task.withTaskCancellationHandler(operation:onCancel:isolation:)`][] method.
763763
For example:
764764

765-
[`Task.withTaskCancellationHandler(operation:onCancel:)`]: https://developer.apple.com/documentation/swift/withtaskcancellationhandler(operation:oncancel:)
765+
[`Task.withTaskCancellationHandler(operation:onCancel:isolation:)`]: https://developer.apple.com/documentation/swift/withtaskcancellationhandler(operation:oncancel:isolation:)
766766

767767
```swift
768768
let task = await Task.withTaskCancellationHandler {
@@ -1431,12 +1431,6 @@ preventing the type from being sendable.
14311431
but maybe link to them?
14321432
-->
14331433

1434-
> Beta Software:
1435-
>
1436-
> This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.
1437-
>
1438-
> Learn more about using [Apple's beta software](https://developer.apple.com/support/beta-software/).
1439-
14401434
<!--
14411435
This source file is part of the Swift.org open source project
14421436

TSPL.docc/LanguageGuide/MemorySafety.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Specifically,
138138
a conflict occurs if you have two accesses
139139
that meet all of the following conditions:
140140

141-
- At least one is a write access or a nonatomic access.
141+
- The accesses aren't both reads, and aren't both atomic.
142142
- They access the same location in memory.
143143
- Their durations overlap.
144144

@@ -152,13 +152,18 @@ for example, a variable, constant, or property.
152152
The duration of a memory access
153153
is either instantaneous or long-term.
154154

155-
An operation is *atomic*
156-
if it uses only C atomic operations;
155+
An access is *atomic* if
156+
it's a call to an atomic operation on [`Atomic`] or [`AtomicLazyReference`],
157+
or it it uses only C atomic operations;
157158
otherwise it's nonatomic.
158-
For a list of those functions, see the `stdatomic(3)` man page.
159+
For a list of C atomic functions, see the `stdatomic(3)` man page.
160+
161+
[`Atomic`]: https://developer.apple.com/documentation/synchronization/atomic
162+
[`AtomicLazyReference`]: https://developer.apple.com/documentation/synchronization/atomiclazyreference
159163

160164
<!--
161-
Using these functions from Swift requires some shimming -- for example:
165+
Using the C atomic functions from Swift
166+
requires some shimming that's out of scope for TSPL - for example:
162167
https://github.com/apple/swift-se-0282-experimental/tree/master/Sources/_AtomicsShims
163168
-->
164169

@@ -742,12 +747,6 @@ it doesn't allow the access.
742747
on performance and memory usage.
743748
-->
744749

745-
> Beta Software:
746-
>
747-
> This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.
748-
>
749-
> Learn more about using [Apple's beta software](https://developer.apple.com/support/beta-software/).
750-
751750
<!--
752751
This source file is part of the Swift.org open source project
753752

TSPL.docc/ReferenceManual/Attributes.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ If there's a stable URL we can use, make the macro protocols below links.
4646
-->
4747

4848
The first argument to this attribute
49-
indicates the macros role:
49+
indicates the macro's role:
5050

5151
- term Peer macros:
5252
Write `peer` as the first argument to this attribute.
@@ -1593,7 +1593,7 @@ s.$x.wrapper // WrapperWithProjection value
15931593

15941594
### resultBuilder
15951595

1596-
Apply this attribute to a class, structure, enumeration
1596+
Apply this attribute to a class, structure, or enumeration
15971597
to use that type as a result builder.
15981598
A *result builder* is a type
15991599
that builds a nested data structure step by step.
@@ -2625,12 +2625,6 @@ see <doc:Statements#Switching-Over-Future-Enumeration-Cases>.
26252625
> *balanced-token* → Any identifier, keyword, literal, or operator \
26262626
> *balanced-token* → Any punctuation except **`(`**, **`)`**, **`[`**, **`]`**, **`{`**, or **`}`**
26272627
2628-
> Beta Software:
2629-
>
2630-
> This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.
2631-
>
2632-
> Learn more about using [Apple's beta software](https://developer.apple.com/support/beta-software/).
2633-
26342628
<!--
26352629
This source file is part of the Swift.org open source project
26362630

TSPL.docc/ReferenceManual/Declarations.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ the term *declaration* covers both declarations and definitions.
3333
> *declaration**subscript-declaration* \
3434
> *declaration**macro-declaration* \
3535
> *declaration**operator-declaration* \
36-
> *declaration**precedence-group-declaration* \
36+
> *declaration**precedence-group-declaration*
3737
3838
## Top-Level Code
3939

@@ -3983,12 +3983,6 @@ as discussed in <doc:AccessControl#Getters-and-Setters>.
39833983
>
39843984
> *actor-isolation-modifier***`nonisolated`**
39853985
3986-
> Beta Software:
3987-
>
3988-
> This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.
3989-
>
3990-
> Learn more about using [Apple's beta software](https://developer.apple.com/support/beta-software/).
3991-
39923986
<!--
39933987
This source file is part of the Swift.org open source project
39943988

TSPL.docc/ReferenceManual/Expressions.md

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ in the sections below.
2020

2121
> Grammar of an expression:
2222
>
23-
> *expression**try-operator*_?_ *await-operator*_?_ *prefix-expression* *infix-expressions*_?_ \
23+
> *expression**try-operator*_?_ *await-operator*_?_ *prefix-expression* *infix-expressions*_?_
2424
2525
## Prefix Expressions
2626

@@ -1520,14 +1520,39 @@ Macro-expansion expressions have the following form:
15201520
A macro-expansion expression omits the parentheses after the macro's name
15211521
if the macro doesn't take any arguments.
15221522

1523-
A macro-expansion expression can't appear as the default value for a parameter,
1524-
except the [`file()`][] and [`line()`][] macros from the Swift standard library.
1523+
A macro-expansion expression can appear as the default value for a parameter.
15251524
When used as the default value of a function or method parameter,
1526-
these macros are evaluated using the source code location of the call site,
1525+
macros are evaluated using the source code location of the call site,
15271526
not the location where they appear in a function definition.
1527+
However, when a default value is a larger expression
1528+
that contains a macro in addition to other code,
1529+
those macros are evaluated where they appear in the function definition.
15281530

1529-
[`file()`]: https://developer.apple.com/documentation/swift/file()
1530-
[`line()`]: https://developer.apple.com/documentation/swift/line()
1531+
```
1532+
func f(a: Int = #line, b: Int = (#line), c: Int = 100 + #line) {
1533+
print(a, b, c)
1534+
}
1535+
f() // Prints "4 1 101"
1536+
```
1537+
1538+
In the function above,
1539+
the default value for `a` is a single macro expression,
1540+
so that macro is evaluated using the source code location
1541+
where `f(a:b:c:)` is called.
1542+
In contrast, the values for `b` and `c`
1543+
are expressions that contain a macro ---
1544+
the macros in those expressions are evaluated
1545+
using the source code location where `f(a:b:c:)` is defined.
1546+
1547+
When you use a macro as a default value,
1548+
it's type checked without expanding the macro,
1549+
to check the following requirements:
1550+
1551+
- The macro's access level
1552+
is the same as or less restrictive than the function that uses it.
1553+
- The macro either takes no arguments,
1554+
or its arguments are literals without string interpolation.
1555+
- The macro's return type matches the parameter's type.
15311556

15321557
You use macro expressions to call freestanding macros.
15331558
To call an attached macro,
@@ -3251,12 +3276,6 @@ someDictionary["a"]?[0] = someFunctionWithSideEffects()
32513276
>
32523277
> *optional-chaining-expression* *postfix-expression* **`?`**
32533278

3254-
> Beta Software:
3255-
>
3256-
> This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.
3257-
>
3258-
> Learn more about using [Apple's beta software](https://developer.apple.com/support/beta-software/).
3259-
32603279
<!--
32613280
This source file is part of the Swift.org open source project
32623281

TSPL.docc/ReferenceManual/LexicalStructure.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,8 @@ so they must be escaped with backticks in that context.
263263
`nonisolated`,
264264
`open`,
265265
`operator`,
266-
`private`,
267266
`precedencegroup`,
267+
`private`,
268268
`protocol`,
269269
`public`,
270270
`rethrows`,
@@ -294,8 +294,8 @@ so they must be escaped with backticks in that context.
294294
`in`,
295295
`repeat`,
296296
`return`,
297-
`throw`,
298297
`switch`,
298+
`throw`,
299299
`where`,
300300
and `while`.
301301
- Keywords used in expressions and types:
@@ -373,6 +373,7 @@ so they must be escaped with backticks in that context.
373373

374374
- Keywords reserved in particular contexts:
375375
`associativity`,
376+
`async`,
376377
`convenience`,
377378
`didSet`,
378379
`dynamic`,
@@ -1251,12 +1252,6 @@ see <doc:AdvancedOperators#Operator-Methods>.
12511252
> *prefix-operator**operator* \
12521253
> *postfix-operator**operator*
12531254
1254-
> Beta Software:
1255-
>
1256-
> This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.
1257-
>
1258-
> Learn more about using [Apple's beta software](https://developer.apple.com/support/beta-software/).
1259-
12601255
<!--
12611256
This source file is part of the Swift.org open source project
12621257

TSPL.docc/ReferenceManual/SummaryOfTheGrammar.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ make the same change here also.
315315

316316
> Grammar of an expression:
317317
>
318-
> *expression**try-operator*_?_ *await-operator*_?_ *prefix-expression* *infix-expressions*_?_ \
318+
> *expression**try-operator*_?_ *await-operator*_?_ *prefix-expression* *infix-expressions*_?_
319319
320320
> Grammar of a prefix expression:
321321
>
@@ -748,7 +748,7 @@ make the same change here also.
748748
> *declaration**extension-declaration* \
749749
> *declaration**subscript-declaration* \
750750
> *declaration**operator-declaration* \
751-
> *declaration**precedence-group-declaration* \
751+
> *declaration**precedence-group-declaration*
752752
753753
> Grammar of a top-level declaration:
754754
>
@@ -1096,12 +1096,6 @@ make the same change here also.
10961096
> *generic-argument-list**generic-argument* | *generic-argument* **`,`** *generic-argument-list* \
10971097
> *generic-argument**type*
10981098
1099-
> Beta Software:
1100-
>
1101-
> This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.
1102-
>
1103-
> Learn more about using [Apple's beta software](https://developer.apple.com/support/beta-software/).
1104-
11051099
<!--
11061100
This source file is part of the Swift.org open source project
11071101

TSPL.docc/ReferenceManual/Types.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ of any type that satisfies the *constraint*.
937937
This behavior contrasts with how an opaque types work,
938938
where there is some specific conforming type known at compile time.
939939
The additional level of indirection that's used
940-
when working with a boxed protocol type is called :newTerm:`boxing`.
940+
when working with a boxed protocol type is called *boxing*.
941941
Boxing typically requires a separate memory allocation for storage
942942
and an additional level of indirection for access,
943943
which incurs a performance cost at runtime.
@@ -1359,12 +1359,6 @@ the expression or one of its subexpressions.
13591359
is allowed and when types must be fully typed.
13601360
-->
13611361

1362-
> Beta Software:
1363-
>
1364-
> This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.
1365-
>
1366-
> Learn more about using [Apple's beta software](https://developer.apple.com/support/beta-software/).
1367-
13681362
<!--
13691363
This source file is part of the Swift.org open source project
13701364

TSPL.docc/RevisionHistory/RevisionHistory.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
Review the recent changes to this book.
44

5-
**XXX release date XXX**
6-
7-
- Minor corrections throughout.
8-
9-
**2024-06-10**
5+
**2024-09-23**
106

117
- Updated for Swift 6.
128
- Added the <doc:Attributes#preconcurrency> section
139
with information about migrating to strict concurrency checking.
1410
- Added the <doc:ErrorHandling#Specifying-the-Error-Type> section
1511
with information about throwing errors of a specific type.
12+
- Updated the <doc:Expressions#Macro-Expansion-Expression> section,
13+
now that any macro can be used as a default value for a parameter.
1614
- Added information about package-level access
1715
to the <doc:AccessControl> chapter.
1816

@@ -852,12 +850,6 @@ Review the recent changes to this book.
852850
for the <doc:BasicOperators#Half-Open-Range-Operator>.
853851
- Added an example of <doc:Generics#Extending-a-Generic-Type>.
854852

855-
> Beta Software:
856-
>
857-
> This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.
858-
>
859-
> Learn more about using [Apple's beta software](https://developer.apple.com/support/beta-software/).
860-
861853
<!--
862854
This source file is part of the Swift.org open source project
863855

0 commit comments

Comments
 (0)